MLIR
19.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) 
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, std::vector< SmallVector< int64_t, 4 >> *lbs=nullptr, SmallVectorImpl< int64_t > *lbDivisors=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 >  getConstantBoundOnDimSize (unsigned pos, SmallVectorImpl< int64_t > *lb=nullptr, int64_t *lbFloorDivisor=nullptr) const 
A wrapper around FlatAffineValueConstraints::getConstantBoundOnDimSize(). 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 

) 
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 nonnull, 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'.
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 2d FlatAffineValueConstraints symbolic in i.
Definition at line 1044 of file Utils.cpp.
Referenced by createPrivateMemRef(), and isFusionProfitable().
std::optional< int64_t > MemRefRegion::getConstantBoundingSizeAndShape  (  SmallVectorImpl< int64_t > *  shape = nullptr , 
std::vector< SmallVector< int64_t, 4 >> *  lbs = nullptr , 

SmallVectorImpl< int64_t > *  lbDivisors = 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 dimensionwise bounds major to minor. The number of elements and all the dimensionwise bounds are guaranteed to be nonnegative. We use int64_t instead of uint64_t since index types can be at most int64_t. lbs
are set to the lower bounds for each of the rank dimensions, and lbDivisors contains the corresponding denominators for floorDivs.
Definition at line 942 of file Utils.cpp.
References mlir::affine::FlatAffineValueConstraints::addBound(), mlir::presburger::IntegerRelation::getConstantBoundOnDimSize64(), and mlir::presburger::IntegerRelation::getNumSymbolVars().
Referenced by createPrivateMemRef(), and generateCopy().

inline 
A wrapper around FlatAffineValueConstraints::getConstantBoundOnDimSize().
'pos' corresponds to the position of the memref shape's dimension (major to minor) which matches 1:1 with the dimensional variable positions in 'cst'.
Definition at line 500 of file Utils.h.
References cst, mlir::presburger::IntegerRelation::getConstantBoundOnDimSize64(), and getRank().

inline 
Definition at line 469 of file Utils.h.
References cst.
Referenced by createPrivateMemRef(), findHighestBlockForPlacement(), generateCopy(), 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 1003 of file Utils.cpp.
References mlir::AffineMap::getNumInputs().
Referenced by generateCopy().
unsigned MemRefRegion::getRank  (  )  const 
Returns the rank of the memref that this region corresponds to.
Definition at line 938 of file Utils.cpp.
Referenced by getConstantBoundOnDimSize().
std::optional< int64_t > MemRefRegion::getRegionSize  (  ) 
Returns the size of this MemRefRegion in bytes.
Definition at line 1215 of file Utils.cpp.
References mlir::affine::getMemRefIntOrFloatEltSizeInBytes().
Referenced by isFusionProfitable().

inline 

inline 
LogicalResult MemRefRegion::unionBoundingBox  (  const MemRefRegion &  other  ) 
Definition at line 1022 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 533 of file Utils.h.
Referenced by getConstantBoundOnDimSize(), and 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 524 of file Utils.h.
Referenced by generateCopy().
Value mlir::affine::MemRefRegion::memref 
Memref that this region corresponds to.
Definition at line 517 of file Utils.h.
Referenced by generateCopy(), mlir::affine::generateCopyForMemRegion(), getMultiLevelStrides(), and unionBoundingBox().
bool mlir::affine::MemRefRegion::write = false 