MLIR  20.0.0git
Namespaces | Macros | Functions
Tiling.cpp File Reference
#include "mlir/Dialect/Linalg/Passes.h"
#include "mlir/Dialect/Affine/IR/AffineOps.h"
#include "mlir/Dialect/Affine/LoopUtils.h"
#include "mlir/Dialect/Arith/Utils/Utils.h"
#include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/Linalg/IR/Linalg.h"
#include "mlir/Dialect/Linalg/Transforms/Transforms.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Dialect/SCF/Transforms/Transforms.h"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
#include "mlir/Dialect/Utils/IndexingUtils.h"
#include "mlir/IR/AffineExpr.h"
#include "mlir/IR/AffineMap.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/ValueRange.h"
#include "mlir/Transforms/FoldUtils.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/CommandLine.h"
#include <utility>
#include "mlir/Dialect/Linalg/Passes.h.inc"
#include "mlir/Dialect/Linalg/IR/LinalgStructuredOps.cpp.inc"

Go to the source code of this file.

Namespaces

 mlir
 Include the generated interface declarations.
 

Macros

#define GEN_PASS_DEF_LINALGTILINGPASS
 
#define DEBUG_TYPE   "linalg-tiling"
 
#define GET_OP_LIST
 

Functions

static void emitIsPositiveIndexAssertion (ImplicitLocOpBuilder &b, OpFoldResult value)
 Asserts that the given index-typed value is strictly positive. More...
 
static bool canOmitTileOffsetInBoundsCheck (OpFoldResult tileSize, OpFoldResult numThreads, OpFoldResult iterationSize)
 Returns true if the maximum tile offset tileSize * numThreads-1 is less than iterationSize. More...
 
static OpFoldResult buildMax (OpBuilder &b, Location loc, ArrayRef< OpFoldResult > vals)
 Build an affine_max of all the vals. More...
 
static OpFoldResult buildMin (OpBuilder &b, Location loc, ArrayRef< OpFoldResult > vals)
 Build an affine_min of all the vals. More...
 
static void calculateTileOffsetsAndSizes (RewriterBase &b, Location loc, scf::ForallOp forallOp, ArrayRef< OpFoldResult > numThreads, SmallVector< Range > loopRanges, bool omitTileOffsetBoundsCheck, std::optional< ArrayRef< OpFoldResult >> nominalTileSizes, SmallVector< OpFoldResult > &tiledOffsets, SmallVector< OpFoldResult > &tiledSizes)
 Fill out the tiledOffsets and tiledSizes to be used to tile to a given number of threads. More...
 
template<typename LoopTy >
static FailureOr< TiledLinalgOptileLinalgOpImpl (RewriterBase &b, LinalgOp op, ArrayRef< OpFoldResult > tileSizes, const LinalgTilingOptions &options)
 
template<typename LoopTy >
static FailureOr< TiledLinalgOptileLinalgOpImpl (RewriterBase &b, LinalgOp op, const LinalgTilingOptions &options)
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "linalg-tiling"

Definition at line 46 of file Tiling.cpp.

◆ GEN_PASS_DEF_LINALGTILINGPASS

#define GEN_PASS_DEF_LINALGTILINGPASS

Definition at line 37 of file Tiling.cpp.

◆ GET_OP_LIST

#define GET_OP_LIST

Function Documentation

◆ buildMax()

static OpFoldResult buildMax ( OpBuilder b,
Location  loc,
ArrayRef< OpFoldResult vals 
)
static

Build an affine_max of all the vals.

Definition at line 350 of file Tiling.cpp.

References mlir::Location::getContext(), mlir::AffineMap::getMultiDimIdentityMap(), and mlir::affine::makeComposedFoldedAffineMax().

◆ buildMin()

static OpFoldResult buildMin ( OpBuilder b,
Location  loc,
ArrayRef< OpFoldResult vals 
)
static

Build an affine_min of all the vals.

Definition at line 358 of file Tiling.cpp.

References mlir::Location::getContext(), mlir::AffineMap::getMultiDimIdentityMap(), and mlir::affine::makeComposedFoldedAffineMin().

◆ calculateTileOffsetsAndSizes()

static void calculateTileOffsetsAndSizes ( RewriterBase b,
Location  loc,
scf::ForallOp  forallOp,
ArrayRef< OpFoldResult numThreads,
SmallVector< Range loopRanges,
bool  omitTileOffsetBoundsCheck,
std::optional< ArrayRef< OpFoldResult >>  nominalTileSizes,
SmallVector< OpFoldResult > &  tiledOffsets,
SmallVector< OpFoldResult > &  tiledSizes 
)
static

Fill out the tiledOffsets and tiledSizes to be used to tile to a given number of threads.

Definition at line 367 of file Tiling.cpp.

References mlir::isConstantIntValue(), and mlir::OpBuilder::setInsertionPointToStart().

◆ canOmitTileOffsetInBoundsCheck()

static bool canOmitTileOffsetInBoundsCheck ( OpFoldResult  tileSize,
OpFoldResult  numThreads,
OpFoldResult  iterationSize 
)
static

Returns true if the maximum tile offset tileSize * numThreads-1 is less than iterationSize.

Definition at line 338 of file Tiling.cpp.

References mlir::getConstantIntValue().

◆ emitIsPositiveIndexAssertion()

static void emitIsPositiveIndexAssertion ( ImplicitLocOpBuilder b,
OpFoldResult  value 
)
static

Asserts that the given index-typed value is strictly positive.

If the value is an attribute, asserts at compile time, otherwise emits an assertion checked at runtime.

Definition at line 94 of file Tiling.cpp.

References mlir::ImplicitLocOpBuilder::create(), and mlir::Builder::getStringAttr().

◆ tileLinalgOpImpl() [1/2]

template<typename LoopTy >
static FailureOr<TiledLinalgOp> tileLinalgOpImpl ( RewriterBase b,
LinalgOp  op,
ArrayRef< OpFoldResult tileSizes,
const LinalgTilingOptions options 
)
static

Definition at line 440 of file Tiling.cpp.

◆ tileLinalgOpImpl() [2/2]

template<typename LoopTy >
static FailureOr<TiledLinalgOp> tileLinalgOpImpl ( RewriterBase b,
LinalgOp  op,
const LinalgTilingOptions options 
)
static

Definition at line 802 of file Tiling.cpp.