MLIR: lib/Dialect/Affine/Utils/Utils.cpp File Reference (original) (raw)
Go to the source code of this file.
Functions | |
---|---|
static void | promoteIfBlock (AffineIfOp ifOp, bool elseBlock) |
Promotes the then or the else block of ifOp (depending on whether elseBlock is false or true) into ifOp's containing block, and discards the rest of the op. More... | |
static Operation * | getOutermostInvariantForOp (AffineIfOp ifOp) |
Returns the outermost affine.for/parallel op that the ifOp is invariant on. More... | |
static AffineIfOp | hoistAffineIfOp (AffineIfOp ifOp, Operation *hoistOverOp) |
A helper for the mechanics of mlir::hoistAffineIfOp. More... | |
static bool | mustReachAtInnermost (const MemRefAccess &srcAccess, const MemRefAccess &destAccess) |
Returns true if the memory operation of destAccess depends on srcAccess inside of the innermost common surrounding affine loop between the two accesses. More... | |
static bool | mayHaveEffect (Operation *srcMemOp, Operation *destMemOp, unsigned minSurroundingLoops) |
Returns true if srcMemOp may have an effect on destMemOp within the scope of the outermost minSurroundingLoops loops that surround them. More... | |
static void | forwardStoreToLoad (AffineReadOpInterface loadOp, SmallVectorImpl< Operation * > &loadOpsToErase, SmallPtrSetImpl< Value > &memrefsToErase, DominanceInfo &domInfo, llvm::function_ref< bool(Value, Value)> mayAlias) |
Attempt to eliminate loadOp by replacing it with a value stored into memory which the load is guaranteed to retrieve. More... | |
template bool | mlir::affine::hasNoInterveningEffect< mlir::MemoryEffects::Read, affine::AffineReadOpInterface > (mlir::Operation *, affine::AffineReadOpInterface, llvm::function_ref< bool(Value, Value)>) |
static void | findUnusedStore (AffineWriteOpInterface writeA, SmallVectorImpl< Operation * > &opsToErase, PostDominanceInfo &postDominanceInfo, llvm::function_ref< bool(Value, Value)> mayAlias) |
static void | loadCSE (AffineReadOpInterface loadA, SmallVectorImpl< Operation * > &loadOpsToErase, DominanceInfo &domInfo, llvm::function_ref< bool(Value, Value)> mayAlias) |
static bool | isDereferencingOp (Operation *op) |
static LogicalResult | getTileSizePos (AffineMap map, SmallVectorImpl< std::tuple< AffineExpr, unsigned, unsigned >> &tileSizePos) |
Check if map is a tiled layout. More... | |
static bool | isNormalizedMemRefDynamicDim (unsigned dim, AffineMap layoutMap, SmallVectorImpl< unsigned > &inMemrefTypeDynDims) |
Check if dim dimension of memrefType with layoutMap becomes dynamic after normalization. More... | |
static AffineExpr | createDimSizeExprForTiledLayout (AffineExpr oldMapOutput, TileExprPattern pat) |
Create affine expr to calculate dimension size for a tiled-layout map. More... | |
template | |
static void | createNewDynamicSizes (MemRefType oldMemRefType, MemRefType newMemRefType, AffineMap map, AllocLikeOp allocOp, OpBuilder b, SmallVectorImpl< Value > &newDynamicSizes) |
Create new maps to calculate each dimension size of newMemRefType, and create newDynamicSizes from them by using AffineApplyOp. More... | |
template LogicalResult | mlir::affine::normalizeMemRef< memref::AllocaOp > (memref::AllocaOp op) |
template LogicalResult | mlir::affine::normalizeMemRef< memref::AllocOp > (memref::AllocOp op) |
static FailureOr< OpFoldResult > | composedAffineMultiply (OpBuilder &b, Location loc, OpFoldResult lhs, OpFoldResult rhs) |
Create an affine map that computes lhs * rhs, composing in any other affine maps. More... | |
◆ DEBUG_TYPE
#define DEBUG_TYPE "affine-utils"
◆ TileExprPattern
Enum to set patterns of affine expr in tiled-layout map.
TileFloorDiv: div TileMod: mod TileNone: None of the above Example: #tiled_2d_128x256 = affine_map<(d0, d1) -> (d0 div 128, d1 div 256, d0 mod 128, d1 mod 256)> "d0 div 128" and "d1 div 256" ==> TileFloorDiv "d0 mod 128" and "d1 mod 256" ==> TileMod
Enumerator |
---|
TileFloorDiv |
TileMod |
TileNone |
Definition at line 1495 of file Utils.cpp.
◆ composedAffineMultiply()
◆ createDimSizeExprForTiledLayout()
◆ createNewDynamicSizes()
template
Create new maps to calculate each dimension size of newMemRefType
, and create newDynamicSizes
from them by using AffineApplyOp.
Steps for normalizing dynamic memrefs for a tiled layout map Example: #map0 = affine_map<(d0, d1) -> (d0, d1 floordiv 32, d1 mod 32)> %0 = dim arg0, c1 :memref<4x?xf32> %1 = alloc(%0) : memref<4x?xf32, #map0>
(Before this function)
- Check if
map
(#map0) is a tiled layout using[getTileSizePos()](Dialect%5F2Affine%5F2Utils%5F2Utils%5F8cpp.html#a533cf0842c1c6bce487e9c42d7593543 "Check if map is a tiled layout.")
. Only single layout map is supported. - Create normalized memrefType using
[isNormalizedMemRefDynamicDim()](Dialect%5F2Affine%5F2Utils%5F2Utils%5F8cpp.html#a98eeb5102e386317908e1de10d00d202 "Check if dim dimension of memrefType with layoutMap becomes dynamic after normalization.")
. It is memref<4x?x?xf32> in the above example.
(In this function)
- Create new maps to calculate each dimension of the normalized memrefType using
[createDimSizeExprForTiledLayout()](Dialect%5F2Affine%5F2Utils%5F2Utils%5F8cpp.html#ab1d1fa11b6b2534b14e10e5214f5a108 "Create affine expr to calculate dimension size for a tiled-layout map.")
. In the tiled layout, the dimension size can be calculated by replacing "floordiv " with "ceildiv " and "mod " with "".
- New map in the above example #map0 = affine_map<(d0, d1) -> (d0)> #map1 = affine_map<(d0, d1) -> (d1 ceildiv 32)> #map2 = affine_map<(d0, d1) -> (32)>
- Create AffineApplyOp to apply the new maps. The output of AffineApplyOp is used in dynamicSizes of new AllocOp. %0 = dim arg0, c1 : memref<4x?xf32> c4 = arith.constant 4 : index %1 = affine.apply #map1(c4, %0) %2 = affine.apply #map2(c4, %0)
Definition at line 1677 of file Utils.cpp.
References mlir::OpBuilder::create(), createDimSizeExprForTiledLayout(), mlir::AffineMap::get(), mlir::Builder::getIndexType(), mlir::Builder::getIntegerAttr(), mlir::AffineMap::getNumInputs(), mlir::AffineMap::getNumSymbols(), mlir::AffineMap::getResults(), getTileSizePos(), TileFloorDiv, TileMod, and TileNone.
Referenced by mlir::affine::normalizeMemRef().
◆ findUnusedStore()
◆ forwardStoreToLoad()
◆ getOutermostInvariantForOp()
static Operation* getOutermostInvariantForOp ( AffineIfOp ifOp) | static |
---|
◆ getTileSizePos()
Check if map
is a tiled layout.
In the tiled layout, specific k dimensions being floordiv'ed by respective tile sizes appeare in a mod with the same tile sizes, and no other expression involves those k dimensions. This function stores a vector of tuples (tileSizePos
) including AffineExpr for tile size, positions of corresponding floordiv
and mod
. If it is not a tiled layout, an empty vector is returned.
Definition at line 1503 of file Utils.cpp.
References mlir::FloorDiv, mlir::AffineBinaryOpExpr::getLHS(), mlir::AffineMap::getResults(), mlir::AffineBinaryOpExpr::getRHS(), and mlir::Mod.
Referenced by createNewDynamicSizes(), mlir::affine::normalizeMemRef(), and mlir::affine::normalizeMemRefType().
◆ hoistAffineIfOp()
static AffineIfOp hoistAffineIfOp ( AffineIfOp ifOp, Operation * hoistOverOp ) | static |
---|
A helper for the mechanics of mlir::hoistAffineIfOp.
Hoists ifOp
just over hoistOverOp
. Returns the new hoisted op if any hoisting happened, otherwise the same ifOp
.
Definition at line 290 of file Utils.cpp.
References mlir::WalkResult::advance(), mlir::IRMapping::clear(), mlir::OpBuilder::clone(), mlir::OpBuilder::create(), mlir::Operation::getBlock(), mlir::Builder::getBoolAttr(), mlir::Block::getOperations(), mlir::Builder::getStringAttr(), mlir::WalkResult::interrupt(), promoteIfBlock(), and mlir::OpBuilder::setInsertionPointAfter().
◆ isDereferencingOp()
static bool isDereferencingOp ( Operation * op) | static |
---|
◆ isNormalizedMemRefDynamicDim()
static bool isNormalizedMemRefDynamicDim ( unsigned dim, AffineMap layoutMap, SmallVectorImpl< unsigned > & inMemrefTypeDynDims ) | static |
---|
Check if dim
dimension of memrefType with layoutMap
becomes dynamic after normalization.
Dimensions that include dynamic dimensions in the map output will become dynamic dimensions. Return true if dim
is dynamic dimension.
Example: #map0 = affine_map<(d0, d1) -> (d0, d1 floordiv 32, d1 mod 32)>
If d1 is dynamic dimension, 2nd and 3rd dimension of map output are dynamic. memref<4x?xf32, #map0> ==> memref<4x?x?xf32>
Definition at line 1602 of file Utils.cpp.
References mlir::WalkResult::advance(), mlir::getAffineDimExpr(), mlir::AffineMap::getContext(), mlir::AffineMap::getResults(), mlir::WalkResult::interrupt(), and mlir::AffineExpr::walk().
Referenced by mlir::affine::normalizeMemRefType().
◆ loadCSE()
◆ mayHaveEffect()
static bool mayHaveEffect ( Operation * srcMemOp, Operation * destMemOp, unsigned minSurroundingLoops ) | static |
---|
◆ mlir::affine::hasNoInterveningEffect< mlir::MemoryEffects::Read, affine::AffineReadOpInterface >()
◆ mlir::affine::normalizeMemRef< memref::AllocaOp >()
◆ mlir::affine::normalizeMemRef< memref::AllocOp >()
◆ mustReachAtInnermost()
◆ promoteIfBlock()
static void promoteIfBlock ( AffineIfOp ifOp, bool elseBlock ) | static |
---|