MLIR
21.0.0git
|
A region of a memref's data space; this is typically constructed by analyzing load/store op's on this memref and the index space of loops surrounding such op's. More...
#include "mlir/Dialect/Affine/Analysis/Utils.h"
Public Member Functions | |
MemRefRegion (Location loc) | |
LogicalResult | compute (Operation *op, unsigned loopDepth, const ComputationSliceState *sliceState=nullptr, bool addMemRefDimBounds=true, bool dropLocalVars=true, bool dropOuterIVs=true) |
Computes the memory region accessed by this memref with the region represented as constraints symbolic/parametric in 'loopDepth' loops surrounding opInst. More... | |
FlatAffineValueConstraints * | getConstraints () |
const FlatAffineValueConstraints * | getConstraints () const |
bool | isWrite () const |
void | setWrite (bool flag) |
std::optional< int64_t > | getConstantBoundingSizeAndShape (SmallVectorImpl< int64_t > *shape=nullptr, SmallVectorImpl< AffineMap > *lbs=nullptr) const |
Returns a constant upper bound on the number of elements in this region if bounded by a known constant (always possible for static shapes), std::nullopt otherwise. More... | |
void | getLowerAndUpperBound (unsigned pos, AffineMap &lbMap, AffineMap &ubMap) const |
Gets the lower and upper bound map for the dimensional variable at pos . More... | |
std::optional< int64_t > | getRegionSize () |
Returns the size of this MemRefRegion in bytes. More... | |
LogicalResult | unionBoundingBox (const MemRefRegion &other) |
unsigned | getRank () const |
Returns the rank of the memref that this region corresponds to. More... | |
Public Attributes | |
Value | memref |
Memref that this region corresponds to. More... | |
bool | write = false |
Read or write. More... | |
Location | loc |
If there is more than one load/store op associated with the region, the location information would correspond to one of those op's. More... | |
FlatAffineValueConstraints | cst |
Region (data space) of the memref accessed. More... | |
A region of a memref's data space; this is typically constructed by analyzing load/store op's on this memref and the index space of loops surrounding such op's.
|
inlineexplicit |
LogicalResult MemRefRegion::compute | ( | Operation * | op, |
unsigned | loopDepth, | ||
const ComputationSliceState * | sliceState = nullptr , |
||
bool | addMemRefDimBounds = true , |
||
bool | dropLocalVars = true , |
||
bool | dropOuterIVs = true |
||
) |
Computes the memory region accessed by this memref with the region represented as constraints symbolic/parametric in 'loopDepth' loops surrounding opInst.
Computes the memory region accessed by this memref with the region represented as constraints symbolic/parametric in 'loopDepth' loops surrounding opInst and any additional Function symbols.
The computed region's 'cst' field has exactly as many dimensional variables as the rank of the memref, and potentially additional symbolic variables which could include any of the loop IVs surrounding opInst up until 'loopDepth' and another additional Function symbols involved with the access (for eg., those appear in affine.apply's, loop bounds, etc.). If 'sliceState' is non-null, operands from 'sliceState' are added as symbols, and the following constraints are added to the system: *) Inequality constraints which represent loop bounds for 'sliceState' operands which are loop IVS (these represent the destination loop IVs of the slice, and are added as symbols to MemRefRegion's constraint system). *) Inequality constraints for the slice bounds in 'sliceState', which represent the bounds on the loop IVs in this constraint system w.r.t to slice operands (which correspond to symbols). If 'addMemRefDimBounds' is true, constant upper/lower bounds [0, memref.getDimSize(i)) are added for each MemRef dimension 'i'. If dropLocalVars
is true, all local variables in cst
are projected out.
For example, the memref region for this operation at loopDepth = 1 will be:
affine.for i = 0 to 32 { affine.for ii = i to (d0) -> (d0 + 8) (i) { load A[ii] } }
{memref = A, write = false, {i <= m0 <= i + 7} } The last field is a 2-d FlatAffineValueConstraints symbolic in i.
If dropOuterIVs
is true, project out any IVs other than those among loopDepth
surrounding IVs, which would be symbols. If dropOuterIVs
is false, the IVs would be turned into local variables instead of being projected out.
Definition at line 1168 of file Utils.cpp.
References mlir::AffineMap::dump(), mlir::Operation::emitError(), mlir::detail::enumerate(), mlir::affine::MemRefAccess::getAccessMap(), mlir::affine::getAffineIVs(), mlir::affine::AffineValueMap::getAffineMap(), mlir::affine::getAffineParallelInductionVarOwner(), mlir::getConstantIntValue(), mlir::affine::getForInductionVarOwner(), mlir::AffineMap::getNumDims(), mlir::affine::AffineValueMap::getNumOperands(), mlir::AffineMap::getNumSymbols(), mlir::affine::AffineValueMap::getOperand(), mlir::affine::MemRefAccess::getRank(), mlir::affine::isAffineInductionVar(), mlir::affine::MemRefAccess::isStore(), mlir::affine::isValidSymbol(), mlir::affine::ComputationSliceState::ivs, mlir::affine::ComputationSliceState::lbOperands, mlir::affine::ComputationSliceState::lbs, mlir::affine::MemRefAccess::memref, and mlir::affine::ComputationSliceState::ubs.
Referenced by createPrivateMemRef(), and isFusionProfitable().
std::optional< int64_t > MemRefRegion::getConstantBoundingSizeAndShape | ( | SmallVectorImpl< int64_t > * | shape = nullptr , |
SmallVectorImpl< AffineMap > * | lbs = nullptr |
||
) | const |
Returns a constant upper bound on the number of elements in this region if bounded by a known constant (always possible for static shapes), std::nullopt otherwise.
Note that the symbols of the region are treated specially, i.e., the returned bounding constant holds for any given value of the symbol variables. The 'shape' vector is set to the corresponding dimension-wise bounds major to minor. The number of elements and all the dimension-wise bounds are guaranteed to be non-negative. We use int64_t instead of uint64_t since index types can be at most int64_t. lbs
are set to the lower bound maps for each of the rank dimensions where each of these maps is purely symbolic in the constraints set's symbols.
Definition at line 1071 of file Utils.cpp.
Referenced by createPrivateMemRef(), and generateCopy().
|
inline |
Definition at line 527 of file Utils.h.
References cst.
Referenced by createPrivateMemRef(), findHighestBlockForPlacement(), generateCopy(), getFullMemRefAsRegion(), and unionBoundingBox().
|
inline |
void MemRefRegion::getLowerAndUpperBound | ( | unsigned | pos, |
AffineMap & | lbMap, | ||
AffineMap & | ubMap | ||
) | const |
Gets the lower and upper bound map for the dimensional variable at pos
.
Definition at line 1127 of file Utils.cpp.
References mlir::AffineMap::getNumInputs().
Referenced by generateCopy().
unsigned MemRefRegion::getRank | ( | ) | const |
std::optional< int64_t > MemRefRegion::getRegionSize | ( | ) |
Returns the size of this MemRefRegion in bytes.
Definition at line 1351 of file Utils.cpp.
References mlir::affine::getMemRefIntOrFloatEltSizeInBytes().
Referenced by isFusionProfitable().
|
inline |
|
inline |
LogicalResult MemRefRegion::unionBoundingBox | ( | const MemRefRegion & | other | ) |
Definition at line 1146 of file Utils.cpp.
References getConstraints(), and memref.
FlatAffineValueConstraints mlir::affine::MemRefRegion::cst |
Region (data space) of the memref accessed.
This set will thus have at least as many dimensional variables as the shape dimensionality of the memref, and these are the leading dimensions of the set appearing in that order (major to minor / outermost to innermost). There may be additional variables since getMemRefRegion() is called with a specific loop depth, and thus the region is symbolic in the outer surrounding loops at that depth.
Definition at line 578 of file Utils.h.
Referenced by getConstraints().
Location mlir::affine::MemRefRegion::loc |
If there is more than one load/store op associated with the region, the location information would correspond to one of those op's.
Definition at line 569 of file Utils.h.
Referenced by generateCopy().
Value mlir::affine::MemRefRegion::memref |
Memref that this region corresponds to.
Definition at line 562 of file Utils.h.
Referenced by findHighestBlockForPlacement(), generateCopy(), mlir::affine::generateCopyForMemRegion(), getFullMemRefAsRegion(), getMultiLevelStrides(), and unionBoundingBox().
bool mlir::affine::MemRefRegion::write = false |