MLIR: lib/Dialect/MemRef/IR/MemRefOps.cpp File Reference (original) (raw)
Go to the source code of this file.
Classes | |
---|---|
struct | AllocaScopeInliner |
Inline an AllocaScopeOp if either the direct parent is an allocation scope or it contains no allocation. More... | |
struct | AllocaScopeHoister |
Move allocations into an allocation scope, if it is legal to move them (e.g. More... | |
struct | CollapseShapeOpMemRefCastFolder |
struct | SubViewReturnTypeCanonicalizer |
Return the canonical type of the result of a subview. More... | |
struct | SubViewCanonicalizer |
A canonicalizer wrapper to replace SubViewOps. More... | |
Functions | |
---|---|
static void | constifyIndexValues (SmallVectorImpl< OpFoldResult > &values, ArrayRef< int64_t > constValues) |
Helper function that sets values[i] to constValues[i] if the latter is a static value, as indicated by ShapedType::kDynamic. More... | |
template | |
static LogicalResult | verifyAllocLikeOp (AllocLikeOp op) |
static bool | isGuaranteedAutomaticAllocation (Operation *op) |
Given an operation, return whether this op is guaranteed to allocate an AutomaticAllocationScopeResource. More... | |
static bool | isOpItselfPotentialAutomaticAllocation (Operation *op) |
Given an operation, return whether this op itself could allocate an AutomaticAllocationScopeResource. More... | |
static bool | lastNonTerminatorInRegion (Operation *op) |
Return whether this op is the last non terminating op in a region. More... | |
static std::map< int64_t, unsigned > | getNumOccurences (ArrayRef< int64_t > vals) |
Return a map with key being elements in vals and data being number of occurences of it. More... | |
static FailureOr< llvm::SmallBitVector > | computeMemRefRankReductionMask (MemRefType originalType, MemRefType reducedType, ArrayRef< OpFoldResult > sizes) |
Given the originalType and a candidateReducedType whose shape is assumed to be a subset of originalType with some 1 entries erased, return the set of indices that specifies which of the entries of originalShape are dropped to obtain reducedShape. More... | |
template | |
static bool | replaceConstantUsesOf (OpBuilder &rewriter, Location loc, Container values, ArrayRef< OpFoldResult > maybeConstants) |
Helper function to perform the replacement of all constant uses of values by a materialized constant extracted from maybeConstants. More... | |
static void | printGlobalMemrefOpTypeAndInitialValue (OpAsmPrinter &p, GlobalOp op, TypeAttr type, Attribute initialValue) |
static ParseResult | parseGlobalMemrefOpTypeAndInitialValue (OpAsmParser &parser, TypeAttr &typeAttr, Attribute &initialValue) |
static LogicalResult | verifyCollapsedShape (Operation *op, ArrayRef< int64_t > collapsedShape, ArrayRef< int64_t > expandedShape, ArrayRef< ReassociationIndices > reassociation, bool allowMultipleDynamicDimsPerGroup) |
Helper function for verifying the shape of ExpandShapeOp and ResultShapeOp result and operand. More... | |
static FailureOr< StridedLayoutAttr > | computeExpandedLayoutMap (MemRefType srcType, ArrayRef< int64_t > resultShape, ArrayRef< ReassociationIndices > reassociation) |
Compute the layout map after expanding a given source MemRef type with the specified reassociation indices. More... | |
static FailureOr< StridedLayoutAttr > | computeCollapsedLayoutMap (MemRefType srcType, ArrayRef< ReassociationIndices > reassociation, bool strict=false) |
Compute the layout map after collapsing a given source MemRef type with the specified reassociation indices. More... | |
static bool | haveCompatibleOffsets (MemRefType t1, MemRefType t2) |
Return true if t1 and t2 have equal offsets (both dynamic or of same static value). More... | |
static bool | haveCompatibleStrides (MemRefType t1, MemRefType t2, const llvm::SmallBitVector &droppedDims) |
Return true if t1 and t2 have equal strides (both dynamic or of same static value). More... | |
static LogicalResult | produceSubViewErrorMsg (SliceVerificationResult result, Operation *op, Type expectedType) |
static MemRefType | getCanonicalSubViewResultType (MemRefType currentResultType, MemRefType currentSourceType, MemRefType sourceType, ArrayRef< OpFoldResult > mixedOffsets, ArrayRef< OpFoldResult > mixedSizes, ArrayRef< OpFoldResult > mixedStrides) |
Compute the canonical result type of a SubViewOp. More... | |
static bool | isTrivialSubViewOp (SubViewOp subViewOp) |
Helper method to check if a subview operation is trivially a no-op. More... | |
static MemRefType | inferTransposeResultType (MemRefType memRefType, AffineMap permutationMap) |
Build a strided memref type by applying permutationMap to memRefType. More... | |
◆ GET_OP_CLASSES
◆ computeCollapsedLayoutMap()
static FailureOr computeCollapsedLayoutMap ( MemRefType srcType, ArrayRef< ReassociationIndices > reassociation, bool strict = false ) | static |
---|
Compute the layout map after collapsing a given source MemRef type with the specified reassociation indices.
Note: All collapsed dims in a reassociation group must be contiguous. It is not possible to check this by inspecting a MemRefType in the general case. If non-contiguity cannot be checked statically, the collapse is assumed to be valid (and thus accepted by this function) unless strict = true
.
Definition at line 2393 of file MemRefOps.cpp.
References mlir::get(), and mlir::SaturatedInteger::wrap().
◆ computeExpandedLayoutMap()
◆ computeMemRefRankReductionMask()
static FailureOrllvm::SmallBitVector computeMemRefRankReductionMask ( MemRefType originalType, MemRefType reducedType, ArrayRef< OpFoldResult > sizes ) | static |
---|
Given the originalType
and a candidateReducedType
whose shape is assumed to be a subset of originalType
with some 1
entries erased, return the set of indices that specifies which of the entries of originalShape
are dropped to obtain reducedShape
.
This accounts for cases where there are multiple unit-dims, but only a subset of those are dropped. For MemRefTypes these can be disambiguated using the strides. If a dimension is dropped the stride must be dropped too.
Definition at line 887 of file MemRefOps.cpp.
References mlir::detail::enumerate(), and getNumOccurences().
Referenced by getCanonicalSubViewResultType().
◆ constifyIndexValues()
◆ getCanonicalSubViewResultType()
Compute the canonical result type of a SubViewOp.
Call inferResultType
to deduce the result type for the given sourceType
. Additionally, reduce the rank of the inferred result type if currentResultType
is lower rank than currentSourceType
. Use this signature if sourceType
is updated together with the result type. In this case, it is important to compute the dropped dimensions using currentSourceType
whose strides align with currentResultType
.
Definition at line 3052 of file MemRefOps.cpp.
References computeMemRefRankReductionMask(), and mlir::get().
◆ getNumOccurences()
static std::map<int64_t, unsigned> getNumOccurences ( ArrayRef< int64_t > vals) | static |
---|
Return a map with key being elements in vals
and data being number of occurences of it.
Use std::map, since the vals
here are strides and the dynamic stride value is the same as the tombstone value for DenseMap<int64_t>
.
Definition at line 872 of file MemRefOps.cpp.
Referenced by computeMemRefRankReductionMask().
◆ haveCompatibleOffsets()
static bool haveCompatibleOffsets ( MemRefType t1, MemRefType t2 ) | static |
---|
Return true if t1
and t2
have equal offsets (both dynamic or of same static value).
Definition at line 2886 of file MemRefOps.cpp.
◆ haveCompatibleStrides()
static bool haveCompatibleStrides ( MemRefType t1, MemRefType t2, const llvm::SmallBitVector & droppedDims ) | static |
---|
Return true if t1
and t2
have equal strides (both dynamic or of same static value).
Dimensions of t1
may be dropped in t2
; these must be marked as dropped in droppedDims
.
Definition at line 2897 of file MemRefOps.cpp.
◆ inferTransposeResultType()
static MemRefType inferTransposeResultType ( MemRefType memRefType, AffineMap permutationMap ) | static |
---|
◆ isGuaranteedAutomaticAllocation()
static bool isGuaranteedAutomaticAllocation ( Operation * op) | static |
---|
◆ isOpItselfPotentialAutomaticAllocation()
static bool isOpItselfPotentialAutomaticAllocation ( Operation * op) | static |
---|
◆ isTrivialSubViewOp()
static bool isTrivialSubViewOp ( SubViewOp subViewOp) | static |
---|
Helper method to check if a subview
operation is trivially a no-op.
This is the case if the all offsets are zero, all strides are 1, and the source shape is same as the size of the subview. In such cases, the subview can be folded into its source.
Definition at line 3116 of file MemRefOps.cpp.
References mlir::detail::enumerate(), and mlir::getConstantIntValue().
◆ lastNonTerminatorInRegion()
static bool lastNonTerminatorInRegion ( Operation * op) | static |
---|
◆ parseGlobalMemrefOpTypeAndInitialValue()
static ParseResult parseGlobalMemrefOpTypeAndInitialValue ( OpAsmParser & parser, TypeAttr & typeAttr, Attribute & initialValue ) | static |
---|
◆ printGlobalMemrefOpTypeAndInitialValue()
static void printGlobalMemrefOpTypeAndInitialValue ( OpAsmPrinter & p, GlobalOp op, TypeAttr type, Attribute initialValue ) | static |
---|
◆ produceSubViewErrorMsg()
◆ replaceConstantUsesOf()
template
◆ verifyAllocLikeOp()
template
static LogicalResult verifyAllocLikeOp ( AllocLikeOp op) | static |
---|