MLIR
20.0.0git
|
Classes | |
class | ExtractSliceFromCollapseHelper |
This class assists with generating IR required to materialize an arbitrary-sized slice from the result of a CollapseShapeOp. More... | |
Typedefs | |
using | ControlConstantExtractSliceFusionFn = std::function< bool(ExtractSliceOp)> |
Function to control the folding of constant and extract slice. More... | |
using | ControlFoldFn = std::function< bool(OpOperand *)> |
Functions | |
void | registerAllExtensions (DialectRegistry ®istry) |
Register all extensions of the Tensor dialect. More... | |
void | registerShardingInterfaceExternalModels (DialectRegistry ®istry) |
bool | preservesStaticInformation (Type source, Type target) |
Returns true if target is a ranked tensor type that preserves static information available in the source ranked tensor type. More... | |
bool | canFoldIntoConsumerOp (CastOp castOp) |
Determines whether tensor::CastOp casts to a more dynamic version of the source tensor. More... | |
bool | canFoldIntoProducerOp (CastOp castOp) |
Determines whether the tensor::CastOp casts to a more static version of the source tensor. More... | |
LogicalResult | foldTensorCast (Operation *op) |
Performs folding of any operand of op if it comes from a tensor::CastOp that can be folded. More... | |
OpFoldResult | getMixedSize (OpBuilder &builder, Location loc, Value value, int64_t dim) |
Return the dimension of the given tensor value. More... | |
SmallVector< OpFoldResult > | getMixedSizes (OpBuilder &builder, Location loc, Value value) |
Return the dimensions of the given tensor value. More... | |
Value | createCanonicalRankReducingExtractSliceOp (OpBuilder &b, Location loc, Value tensor, RankedTensorType targetType) |
Create a rank-reducing ExtractSliceOp @[0 . More... | |
Value | createCanonicalRankReducingInsertSliceOp (OpBuilder &b, Location loc, Value tensor, Value dest) |
Create a rank-reducing InsertSliceOp @[0 . More... | |
FailureOr< Value > | getOrCreateDestination (OpBuilder &b, Location loc, OpResult opResult) |
This is a helper function for DestinationStyleOpInterface. More... | |
LogicalResult | getOrCreateDestinations (OpBuilder &b, Location loc, Operation *op, SmallVector< Value > &result) |
This is a helper function for DestinationStyleOpInterface. More... | |
bool | isSameTypeWithoutEncoding (Type tp1, Type tp2) |
Tests if types are the same when ignoring encoding on ranked tensors. More... | |
void | populateFoldConstantExtractSlicePatterns (RewritePatternSet &patterns, const ControlConstantExtractSliceFusionFn &controlFn=[](ExtractSliceOp op) { return false;}) |
Patterns to fold the extract slice op with its constant operand. More... | |
void | registerInferTypeOpInterfaceExternalModels (mlir::DialectRegistry ®istry) |
Registers external models for Infer Type interfaces for tensor ops. More... | |
FailureOr< TilingResult > | bubbleUpPadSlice (OpBuilder &b, tensor::PadOp padOp, ArrayRef< OpFoldResult > offsets, ArrayRef< OpFoldResult > sizes, bool generateZeroSliceGuard=true) |
Bubbles up a slice of this pad by taking the slice first and then performing the padding. More... | |
void | registerTilingInterfaceExternalModels (mlir::DialectRegistry ®istry) |
Registers external models for Tiling interface for tensor ops. More... | |
void | registerTilingInterfaceExternalModelsForPackUnPackOps (DialectRegistry ®istry) |
Similar to the above registeration, but it is only for tensor.pack and tensor.unpack ops. More... | |
void | registerValueBoundsOpInterfaceExternalModels (DialectRegistry ®istry) |
void | registerTransformDialectExtension (DialectRegistry ®istry) |
void | registerFindPayloadReplacementOpInterfaceExternalModels (DialectRegistry ®istry) |
void | registerBufferizableOpInterfaceExternalModels (DialectRegistry ®istry) |
std::unique_ptr< Pass > | createFoldTensorSubsetOpsPass () |
Creates an instance of the tensor subset folding pass. More... | |
void | registerSubsetOpInterfaceExternalModels (DialectRegistry ®istry) |
FailureOr< TilingResult > | replaceExtractSliceWithTiledProducer (OpBuilder &builder, tensor::ExtractSliceOp sliceOp, OpResult producerOp) |
Method to swap an tensor.extract_slice with its producer when the producer implements the TilingInterface . More... | |
FailureOr< TilingResult > | replaceInsertSliceWithTiledConsumer (OpBuilder &builder, OffsetSizeAndStrideOpInterface sliceOp, OpOperand &consumerOp) |
Method to swap an tensor.insert_slice with its consumer when the consumer implements the TilingInterface . More... | |
void | populateFoldTensorSubsetOpPatterns (RewritePatternSet &patterns) |
Appends patterns for folding tensor subset ops into consumer load/store ops into patterns . More... | |
void | populateFoldTensorSubsetIntoVectorTransferPatterns (RewritePatternSet &patterns) |
Appends patterns for folding tensor subset ops into vector transfer ops. More... | |
void | populateMergeConsecutiveInsertExtractSlicePatterns (RewritePatternSet &patterns) |
Collects patterns to merge consecutive tensor.insert_slice/extract_slice into one. More... | |
void | populateDropRedundantInsertSliceRankExpansionPatterns (RewritePatternSet &patterns) |
Populates patterns with patterns that drop redundant tensor.insert_slice rank expansions. More... | |
void | populateReassociativeReshapeFoldingPatterns (RewritePatternSet &patterns) |
Populates patterns with patterns that fold tensor.expand_shape and tensor.collapse_shape into other ops. More... | |
void | populateBubbleUpExpandShapePatterns (RewritePatternSet &patterns) |
Populates patterns with patterns that bubble up tensor.expand_shape through tensor.collapse_shape ops. More... | |
void | populateFoldTensorEmptyPatterns (RewritePatternSet &patterns, bool foldSingleUseOnly=false) |
Populates patterns with patterns that fold tensor.empty with its consumers. More... | |
void | populateDecomposeTensorConcatPatterns (RewritePatternSet &patterns) |
Populates patterns with patterns that decompose tensor.concat into tensor.empty of a tensor of the concatenated size, followed by a chain of tensor.insert_slice operations on the inputs. More... | |
void | populateSimplifyPackAndUnpackPatterns (RewritePatternSet &patterns) |
Populates patterns with patterns that simplify tensor.pack and tensor.unpack operations. More... | |
void | populateFoldIntoPackAndUnpackPatterns (RewritePatternSet &patterns) |
Populates patterns with patterns that fold operations like tensor.pad and tensor.extract_slice into tensor.pack and tensor.unpack operations respectively. More... | |
void | populateRewriteAsConstantPatterns (RewritePatternSet &patterns, const ControlFoldFn &controlFn) |
Populates patterns with patterns that replace tensor ops (such as tensor.generate) with constants when possible. More... | |
FailureOr< Value > | buildIndependentOp (OpBuilder &b, tensor::PadOp padOp, ValueRange independencies) |
Build a new tensor::PadOp with low/high padding that is independent of all given independencies. More... | |
FailureOr< Value > | buildIndependentOp (OpBuilder &b, tensor::EmptyOp emptyOp, ValueRange independencies) |
Build a new tensor::EmptyOp who's dynamic sizes are independent of all given independencies. More... | |
FailureOr< Operation * > | simplifyCollapseShapeWithRankReducingExtractSlice (tensor::CollapseShapeOp op, RewriterBase &rewriter) |
Tries to simplify a tensor.collapse_shape operation by inserting a single rank-reducing tensor.extract_slice operation. More... | |
PadOp | createPadHighOp (RankedTensorType resType, Value source, Value pad, bool nofold, Location loc, OpBuilder &builder, SmallVector< Value > dynOutDim={}) |
SmallVector< Value > | createDynamicDimValues (OpBuilder &b, Location loc, Value rankedTensor) |
FailureOr< RankedTensorType > | computeTransposedType (RankedTensorType rankedTensorType, ArrayRef< int64_t > transposeVector) |
Returns the transposed rankedTensorType if transposeVector is non-empty. More... | |
SmallVector< int64_t > | getPackInverseDestPerm (tensor::PackOp packOp) |
Shell function to compute the Destination Permutation of PackOp This function uses the helper function computePackUnPackPerm to get the permutation vector. More... | |
SmallVector< int64_t > | getUnPackInverseSrcPerm (tensor::UnPackOp unpackOp) |
Shell function to compute the Source Permutation of unPackOp. More... | |
SmallVector< int64_t > | getUnPackInverseSrcPerm (tensor::UnPackOp, PackingMetadata &metadata) |
Shell function to compute the Source rank permutation for unpackOp Unpack requires some packing metadata data information, so created another function where this value is passed by reference. More... | |
bool | isCastLikeInsertSliceOp (InsertSliceOp op) |
A tensor.insert_slice is a cast-like operation if it merely rank-extends the source tensor or inserts the source tensor into a destination tensor with the same shape. More... | |
bool | isCastLikeExtractSliceOp (ExtractSliceOp op) |
A tensor.extract_slice is a cast-like operation if it merely rank-reduces unit dimensions of the source tensor or extracts the entire source tensor. More... | |
using mlir::tensor::ControlConstantExtractSliceFusionFn = typedef std::function<bool(ExtractSliceOp)> |
using mlir::tensor::ControlFoldFn = typedef std::function<bool(OpOperand *)> |
Definition at line 98 of file Transforms.h.
FailureOr< TilingResult > mlir::tensor::bubbleUpPadSlice | ( | OpBuilder & | b, |
tensor::PadOp | padOp, | ||
ArrayRef< OpFoldResult > | offsets, | ||
ArrayRef< OpFoldResult > | sizes, | ||
bool | generateZeroSliceGuard = true |
||
) |
Bubbles up a slice of this pad by taking the slice first and then performing the padding.
offsets
and strides
specifies each dimension's start offset and size for the slice. The slice has unit strides along all dimensions.
Specifically, this function converts:
into
If generateZeroSliceGuard
is true, the generated IR will contain logic to guard against the case that we might take a zero-sized slice from the original source. For such cases, we tensor.generate
to generate the full tensor.
Definition at line 720 of file TensorTilingInterfaceImpl.cpp.
References mlir::bindDims(), mlir::OpBuilder::create(), mlir::dispatchIndexOpFoldResults(), mlir::AffineMap::get(), mlir::get(), mlir::Builder::getContext(), mlir::Builder::getIndexAttr(), getMixedSize(), mlir::AffineMap::getMultiDimIdentityMap(), mlir::getPrunedAttributeList(), mlir::Operation::getResult(), mlir::getValueOrCreateConstantIndexOp(), mlir::isConstantIntValue(), mlir::affine::makeComposedFoldedAffineApply(), mlir::affine::makeComposedFoldedAffineMax(), mlir::affine::makeComposedFoldedAffineMin(), max(), and min().
Referenced by mlir::linalg::ExtractSliceOfPadTensorSwapPattern::matchAndRewrite().
FailureOr< Value > mlir::tensor::buildIndependentOp | ( | OpBuilder & | b, |
tensor::EmptyOp | emptyOp, | ||
ValueRange | independencies | ||
) |
Build a new tensor::EmptyOp who's dynamic sizes are independent of all given independencies.
If the op is already independent of all independencies, the same EmptyOp result is returned.
Failure indicates the no suitable upper bound for the dynamic sizes could be found.
Definition at line 107 of file IndependenceTransforms.cpp.
References mlir::OpBuilder::create(), mlir::Builder::getIndexAttr(), makeIndependent(), and mlir::OpBuilder::setInsertionPoint().
FailureOr< Value > mlir::tensor::buildIndependentOp | ( | OpBuilder & | b, |
tensor::PadOp | padOp, | ||
ValueRange | independencies | ||
) |
Build a new tensor::PadOp with low/high padding that is independent of all given independencies.
If the op is already independent of all independencies, the same PadOp result is returned.
Failure indicates the no suitable upper bound for low/high padding could be found.
Example: scf.for iv = lb to ub step step { high = affine.apply affine_map<(d0)[s0] -> (s0 - d0)> (i)[ub] p = tensor.pad t low[5] high[high] ... ... }
The function builds IR such as: high_new = affine.apply affine_map<()[s0, s1] -> (-s0 + s1)> ()[lb, ub] p_hoistable = tensor.pad t low[5] high[high_new] dim = tensor.dim t, c0 size = affine.apply affine_map<(d0)[s0, s1] -> (-d0 + s0 + s1 + 5)> (iv)[ub, dim] slice = tensor.extract_slice p_hoistable [0] [size] [1]
The slice is returned.
Definition at line 37 of file IndependenceTransforms.cpp.
References mlir::OpBuilder::create(), mlir::Builder::getAffineDimExpr(), mlir::Builder::getIndexAttr(), mlir::Operation::getResult(), makeIndependent(), and mlir::OpBuilder::setInsertionPoint().
bool mlir::tensor::canFoldIntoConsumerOp | ( | CastOp | castOp | ) |
Determines whether tensor::CastOp casts to a more dynamic version of the source tensor.
This is useful to fold a tensor.cast into a consuming op and implement canonicalization patterns for ops in different dialects that may consume the results of tensor.cast operations. Such foldable tensor.cast operations are typically inserted as extract_slice
ops and are canonicalized, to preserve the type compatibility of their uses.
Returns true when all conditions are met:
Example:
folds into:
This is useful to fold a tensor.cast into a consuming op and implement canonicalization patterns for ops in different dialects that may consume the results of tensor.cast operations. Such foldable tensor.cast operations are typically inserted as slice
ops and are canonicalized, to preserve the type compatibility of their uses.
Returns true when all conditions are met:
Example:
folds into:
Definition at line 317 of file TensorOps.cpp.
References preservesStaticInformation().
bool mlir::tensor::canFoldIntoProducerOp | ( | CastOp | castOp | ) |
Determines whether the tensor::CastOp casts to a more static version of the source tensor.
This is useful to fold into a producing op and implement canonicaliation patterns with the tensor.cast
op as the root, but producer being from different dialects. Returns true when all conditions are met:
Example:
can be canonicalized to :
Not all ops might be canonicalizable this way, but for those that can be, this method provides a check that it is worth doing the canonicalization.
Definition at line 347 of file TensorOps.cpp.
References preservesStaticInformation().
FailureOr< RankedTensorType > mlir::tensor::computeTransposedType | ( | RankedTensorType | rankedTensorType, |
ArrayRef< int64_t > | transposeVector | ||
) |
Returns the transposed rankedTensorType
if transposeVector
is non-empty.
Fail if transposeVector
is not a permutation matching the tensor rank.
Definition at line 77 of file Utils.cpp.
References mlir::applyPermutationToVector(), mlir::isPermutationVector(), and mlir::RankedTensorType::Builder::setShape().
Referenced by buildPackingLoopNestImpl(), and mlir::linalg::hoistPaddingOnTensors().
Value mlir::tensor::createCanonicalRankReducingExtractSliceOp | ( | OpBuilder & | b, |
Location | loc, | ||
Value | tensor, | ||
RankedTensorType | targetType | ||
) |
Create a rank-reducing ExtractSliceOp @[0 .
. 0] with strides [1 .. 1] and appropriate sizes (i.e. tensor.getSizes()
) to reduce the rank of tensor
to that of targetType
.
Definition at line 2489 of file TensorOps.cpp.
References mlir::OpBuilder::createOrFold(), mlir::Builder::getIndexAttr(), getMixedSizes(), and mlir::Value::getType().
Referenced by mlir::linalg::DownscaleConv2DOp::returningMatchAndRewrite(), and mlir::linalg::DownscaleDepthwiseConv2DNhwcHwcOp::returningMatchAndRewrite().
Value mlir::tensor::createCanonicalRankReducingInsertSliceOp | ( | OpBuilder & | b, |
Location | loc, | ||
Value | tensor, | ||
Value | dest | ||
) |
Create a rank-reducing InsertSliceOp @[0 .
. 0] with strides [1 .. 1] and appropriate sizes (i.e. dest.getSizes()
). The result is a new tensor with rank increased to that of dest
, obtained by inserting tensor
into dest
at the canonical [0 .. 0] position.
Definition at line 2868 of file TensorOps.cpp.
References mlir::OpBuilder::createOrFold(), mlir::Builder::getIndexAttr(), getMixedSizes(), and mlir::Value::getType().
Referenced by mlir::linalg::DownscaleConv2DOp::returningMatchAndRewrite(), and mlir::linalg::DownscaleDepthwiseConv2DNhwcHwcOp::returningMatchAndRewrite().
SmallVector< Value > mlir::tensor::createDynamicDimValues | ( | OpBuilder & | b, |
Location | loc, | ||
Value | rankedTensor | ||
) |
Definition at line 63 of file Utils.cpp.
References mlir::OpBuilder::create(), mlir::detail::enumerate(), and mlir::Value::getType().
std::unique_ptr< Pass > mlir::tensor::createFoldTensorSubsetOpsPass | ( | ) |
Creates an instance of the tensor
subset folding pass.
Definition at line 283 of file FoldTensorSubsetOps.cpp.
PadOp mlir::tensor::createPadHighOp | ( | RankedTensorType | resType, |
Value | source, | ||
Value | pad, | ||
bool | nofold, | ||
Location | loc, | ||
OpBuilder & | builder, | ||
SmallVector< Value > | dynOutDim = {} |
||
) |
Definition at line 25 of file Utils.cpp.
References mlir::bindDims(), mlir::OpBuilder::create(), mlir::detail::enumerate(), mlir::Builder::getContext(), mlir::Builder::getIndexAttr(), getMixedSize(), and mlir::affine::makeComposedFoldedAffineApply().
Referenced by getPackOpSourceOrPaddedSource(), and mlir::linalg::makeComposedPadHighOp().
LogicalResult mlir::tensor::foldTensorCast | ( | Operation * | op | ) |
Performs folding of any operand of op
if it comes from a tensor::CastOp that can be folded.
Definition at line 356 of file TensorOps.cpp.
OpFoldResult mlir::tensor::getMixedSize | ( | OpBuilder & | builder, |
Location | loc, | ||
Value | value, | ||
int64_t | dim | ||
) |
Return the dimension of the given tensor value.
Definition at line 55 of file TensorOps.cpp.
References mlir::OpBuilder::createOrFold(), mlir::Builder::getIndexAttr(), and mlir::Value::getType().
Referenced by bubbleUpPadSlice(), createPadHighOp(), getMixedSizes(), mlir::linalg::lowerPack(), mlir::linalg::GeneralizePadOpPattern::matchAndRewrite(), and mlir::linalg::GeneralizeOuterUnitDimsUnPackOpPattern::matchAndRewrite().
SmallVector< OpFoldResult > mlir::tensor::getMixedSizes | ( | OpBuilder & | builder, |
Location | loc, | ||
Value | value | ||
) |
Return the dimensions of the given tensor value.
Definition at line 65 of file TensorOps.cpp.
References getMixedSize(), and mlir::Value::getType().
Referenced by createCanonicalRankReducingExtractSliceOp(), createCanonicalRankReducingInsertSliceOp(), mlir::vector::createReadOrMaskedRead(), expandValue(), mlir::vector::getMixedSizesXfer(), mlir::linalg::lowerPack(), mlir::linalg::lowerUnPack(), mlir::linalg::GeneralizeOuterUnitDimsPackOpPattern::matchAndRewrite(), mlir::linalg::GeneralizePadOpPattern::matchAndRewrite(), and mlir::linalg::rewriteInDestinationPassingStyle().
FailureOr< Value > mlir::tensor::getOrCreateDestination | ( | OpBuilder & | b, |
Location | loc, | ||
OpResult | opResult | ||
) |
This is a helper function for DestinationStyleOpInterface.
If there is a destination operand for the given OpResult, return that operand. Otherwise, return an empty tensor (tensor.empty
) with the shape of the OpResult. Dynamic dimensions are queried via ReifyRankedShapedTypeOpInterface.
Definition at line 74 of file TensorOps.cpp.
References mlir::OpBuilder::create(), mlir::Value::getDefiningOp(), mlir::Builder::getIndexAttr(), mlir::OpResult::getResultNumber(), mlir::Value::getType(), mlir::reifyResultShapes(), and mlir::OpBuilder::setInsertionPoint().
Referenced by mlir::scf::yieldReplacementForFusedProducer().
LogicalResult mlir::tensor::getOrCreateDestinations | ( | OpBuilder & | b, |
Location | loc, | ||
Operation * | op, | ||
SmallVector< Value > & | result | ||
) |
This is a helper function for DestinationStyleOpInterface.
Get or create destinations for every tensor OpResult of the given op.
Definition at line 109 of file TensorOps.cpp.
Referenced by tileAndFuseFirstExtractUseThroughContainingOpBlockArgument(), and mlir::scf::tileAndFuseProducerOfSlice().
SmallVector<int64_t> mlir::tensor::getPackInverseDestPerm | ( | tensor::PackOp | packOp | ) |
Shell function to compute the Destination Permutation of PackOp This function uses the helper function computePackUnPackPerm
to get the permutation vector.
Only major difference between UnPack and Pack is that packOp uses destination rank whereas unpack Uses source rank.
Referenced by getTiledPackShape(), mlir::linalg::lowerPack(), and vectorizeAsTensorPackOp().
SmallVector<int64_t> mlir::tensor::getUnPackInverseSrcPerm | ( | tensor::UnPackOp | unpackOp | ) |
Shell function to compute the Source Permutation of unPackOp.
This function, like the getPackInverseDestPerm uses the helper function computePackUnPackPerm` to get the permutation vector. Only major difference between UnPack and Pack is that packOp uses destination rank whereas unpack Uses source rank.
Referenced by mlir::linalg::lowerUnPack(), and vectorizeAsTensorUnpackOp().
SmallVector<int64_t> mlir::tensor::getUnPackInverseSrcPerm | ( | tensor::UnPackOp | , |
PackingMetadata & | metadata | ||
) |
Shell function to compute the Source rank permutation for unpackOp Unpack requires some packing metadata data information, so created another function where this value is passed by reference.
bool mlir::tensor::isCastLikeExtractSliceOp | ( | ExtractSliceOp | op | ) |
bool mlir::tensor::isCastLikeInsertSliceOp | ( | InsertSliceOp | op | ) |
Tests if types are the same when ignoring encoding on ranked tensors.
Definition at line 123 of file TensorOps.cpp.
void mlir::tensor::populateBubbleUpExpandShapePatterns | ( | RewritePatternSet & | patterns | ) |
Populates patterns
with patterns that bubble up tensor.expand_shape
through tensor.collapse_shape
ops.
Definition at line 226 of file ReshapePatterns.cpp.
References mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::getContext().
void mlir::tensor::populateDecomposeTensorConcatPatterns | ( | RewritePatternSet & | patterns | ) |
Populates patterns
with patterns that decompose tensor.concat
into tensor.empty
of a tensor of the concatenated size, followed by a chain of tensor.insert_slice
operations on the inputs.
This is intended to be used as a fallback tensor -> tensor lowering that decomposes concat such that it can be bufferized into a sequence of copies.
Definition at line 90 of file ConcatOpPatterns.cpp.
References mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::getContext().
void mlir::tensor::populateDropRedundantInsertSliceRankExpansionPatterns | ( | RewritePatternSet & | patterns | ) |
Populates patterns
with patterns that drop redundant tensor.insert_slice rank expansions.
Definition at line 238 of file MergeConsecutiveInsertExtractSlicePatterns.cpp.
References mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::getContext().
void mlir::tensor::populateFoldConstantExtractSlicePatterns | ( | RewritePatternSet & | patterns, |
const ControlConstantExtractSliceFusionFn & | controlFn = [](ExtractSliceOp op) { return false; } |
||
) |
Patterns to fold the extract slice op with its constant operand.
Definition at line 2402 of file TensorOps.cpp.
References mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::getContext().
void mlir::tensor::populateFoldIntoPackAndUnpackPatterns | ( | RewritePatternSet & | patterns | ) |
Populates patterns
with patterns that fold operations like tensor.pad
and tensor.extract_slice
into tensor.pack
and tensor.unpack
operations respectively.
Definition at line 484 of file PackAndUnpackPatterns.cpp.
References mlir::RewritePatternSet::getContext(), and mlir::RewritePatternSet::insert().
void mlir::tensor::populateFoldTensorEmptyPatterns | ( | RewritePatternSet & | patterns, |
bool | foldSingleUseOnly = false |
||
) |
Populates patterns
with patterns that fold tensor.empty with its consumers.
If singleUseOnly
is set to "true", only tensor.empty ops with a single use are folded.
Definition at line 173 of file EmptyOpPatterns.cpp.
References mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::getContext().
Referenced by populateFoldUnitExtentDimsViaReshapesPatterns(), and populateFoldUnitExtentDimsViaSlicesPatterns().
void mlir::tensor::populateFoldTensorSubsetIntoVectorTransferPatterns | ( | RewritePatternSet & | patterns | ) |
Appends patterns for folding tensor subset ops into vector transfer ops.
Definition at line 258 of file FoldTensorSubsetOps.cpp.
References mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::getContext().
Referenced by populateFoldTensorSubsetOpPatterns().
void mlir::tensor::populateFoldTensorSubsetOpPatterns | ( | RewritePatternSet & | patterns | ) |
Appends patterns for folding tensor subset ops into consumer load/store ops into patterns
.
(This includes patterns for folding tensor subset ops into vector transfer ops.)
Definition at line 251 of file FoldTensorSubsetOps.cpp.
References mlir::RewritePatternSet::add(), mlir::RewritePatternSet::getContext(), and populateFoldTensorSubsetIntoVectorTransferPatterns().
void mlir::tensor::populateMergeConsecutiveInsertExtractSlicePatterns | ( | RewritePatternSet & | patterns | ) |
Collects patterns to merge consecutive tensor.insert_slice/extract_slice into one.
These patterns are in this separate entry point because the bufferization is sensitive to IR structure, particularly those tensor.extract_slice and tensor.insert_slice ops for creating the slices.
Definition at line 230 of file MergeConsecutiveInsertExtractSlicePatterns.cpp.
References mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::getContext().
void mlir::tensor::populateReassociativeReshapeFoldingPatterns | ( | RewritePatternSet & | patterns | ) |
Populates patterns
with patterns that fold tensor.expand_shape
and tensor.collapse_shape
into other ops.
Definition at line 215 of file ReshapePatterns.cpp.
References mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::getContext().
void mlir::tensor::populateRewriteAsConstantPatterns | ( | RewritePatternSet & | patterns, |
const ControlFoldFn & | controlFn | ||
) |
Populates patterns
with patterns that replace tensor ops (such as tensor.generate) with constants when possible.
Definition at line 211 of file RewriteAsConstant.cpp.
References mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::getContext().
void mlir::tensor::populateSimplifyPackAndUnpackPatterns | ( | RewritePatternSet & | patterns | ) |
Populates patterns
with patterns that simplify tensor.pack
and tensor.unpack
operations.
Definition at line 493 of file PackAndUnpackPatterns.cpp.
References mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::getContext().
Returns true if target
is a ranked tensor type that preserves static information available in the source
ranked tensor type.
Definition at line 265 of file TensorOps.cpp.
Referenced by canFoldIntoConsumerOp(), and canFoldIntoProducerOp().
void mlir::tensor::registerAllExtensions | ( | DialectRegistry & | registry | ) |
Register all extensions of the Tensor dialect.
This should generally only be used by tools, or other use cases that really do want all extensions of the dialect. All other cases should prefer to instead register the specific extensions they intend to take advantage of.
Definition at line 14 of file AllExtensions.cpp.
References mlir::func::registerShardingInterfaceExternalModels().
Referenced by mlir::registerAllExtensions().
void mlir::tensor::registerBufferizableOpInterfaceExternalModels | ( | DialectRegistry & | registry | ) |
Definition at line 1056 of file BufferizableOpInterfaceImpl.cpp.
References mlir::DialectRegistry::addExtension(), mlir::MLIRContext::loadDialect(), and registerSubsetOpInterfaceExternalModels().
Referenced by mlir::registerAllDialects().
void mlir::tensor::registerFindPayloadReplacementOpInterfaceExternalModels | ( | DialectRegistry & | registry | ) |
Definition at line 71 of file TensorTransformOps.cpp.
References mlir::DialectRegistry::addExtension().
Referenced by mlir::registerAllDialects().
void mlir::tensor::registerInferTypeOpInterfaceExternalModels | ( | mlir::DialectRegistry & | registry | ) |
Registers external models for Infer Type interfaces for tensor ops.
Currently, it registers:
tensor.collapse_shape
.tensor.expand_shape
.Unfortunately, a "normal" internal registration is not possible at the moment, because of the dependency of the interface implementation for these ops on affine.apply
and Affine dialect already depends on TensorOps. In order to break the cyclic dependency (TensorOps->AffineOps->TensorOps) the implementation is moved to a separate library.
Definition at line 202 of file TensorInferTypeOpInterfaceImpl.cpp.
References mlir::DialectRegistry::addExtension().
Referenced by mlir::registerAllDialects().
void mlir::tensor::registerShardingInterfaceExternalModels | ( | DialectRegistry & | registry | ) |
Definition at line 99 of file MeshShardingExtensions.cpp.
References mlir::DialectRegistry::addExtension().
void mlir::tensor::registerSubsetOpInterfaceExternalModels | ( | DialectRegistry & | registry | ) |
Definition at line 87 of file SubsetInsertionOpInterfaceImpl.cpp.
References mlir::DialectRegistry::addExtension().
Referenced by mlir::registerAllDialects(), and registerBufferizableOpInterfaceExternalModels().
void mlir::tensor::registerTilingInterfaceExternalModels | ( | mlir::DialectRegistry & | registry | ) |
Registers external models for Tiling interface for tensor ops.
Currently, it registers:
tensor.pad
, tensor.pack
, and tensor.unpack
.Unfortunately, a "normal" internal registration is not possible at the moment, because of the dependency of the interface implementation for these ops on affine.apply
and Affine dialect already depends on TensorOps. In order to break the cyclic dependency (TensorOps->AffineOps->TensorOps) the implementation is moved to a separate library.
Definition at line 935 of file TensorTilingInterfaceImpl.cpp.
References mlir::DialectRegistry::addExtension().
Referenced by mlir::registerAllDialects().
void mlir::tensor::registerTilingInterfaceExternalModelsForPackUnPackOps | ( | DialectRegistry & | registry | ) |
Similar to the above registeration, but it is only for tensor.pack
and tensor.unpack
ops.
Definition at line 944 of file TensorTilingInterfaceImpl.cpp.
References mlir::DialectRegistry::addExtension().
void mlir::tensor::registerTransformDialectExtension | ( | DialectRegistry & | registry | ) |
Definition at line 258 of file TensorTransformOps.cpp.
References mlir::DialectRegistry::addExtensions().
Referenced by mlir::registerAllExtensions().
void mlir::tensor::registerValueBoundsOpInterfaceExternalModels | ( | DialectRegistry & | registry | ) |
Definition at line 115 of file ValueBoundsOpInterfaceImpl.cpp.
References mlir::DialectRegistry::addExtension().
Referenced by mlir::registerAllDialects().
FailureOr< TilingResult > mlir::tensor::replaceExtractSliceWithTiledProducer | ( | OpBuilder & | builder, |
tensor::ExtractSliceOp | sliceOp, | ||
OpResult | producerOp | ||
) |
Method to swap an tensor.extract_slice
with its producer when the producer implements the TilingInterface
.
The pattern itself does not provide a mechanism to control where the application happens. With use of transform dialect that control is done within the transform dialect. Other use cases can inherit from this pattern and add necessary controls.
Definition at line 23 of file SwapExtractSliceWithProducerPatterns.cpp.
References mlir::OpResult::getOwner(), and mlir::OpResult::getResultNumber().
Referenced by mlir::scf::tileAndFuseProducerOfSlice().
FailureOr< TilingResult > mlir::tensor::replaceInsertSliceWithTiledConsumer | ( | OpBuilder & | builder, |
OffsetSizeAndStrideOpInterface | sliceOp, | ||
OpOperand & | consumerOp | ||
) |
Method to swap an tensor.insert_slice
with its consumer when the consumer implements the TilingInterface
.
Definition at line 44 of file SwapExtractSliceWithProducerPatterns.cpp.
References mlir::OpOperand::getOperandNumber(), and mlir::detail::IROperandBase::getOwner().
Referenced by mlir::scf::tileAndFuseConsumerOfSlice().
FailureOr< Operation * > mlir::tensor::simplifyCollapseShapeWithRankReducingExtractSlice | ( | tensor::CollapseShapeOp | op, |
RewriterBase & | rewriter | ||
) |
Tries to simplify a tensor.collapse_shape
operation by inserting a single rank-reducing tensor.extract_slice
operation.
The extract_slice
op will either take the place of the source, allowing for a new, simpler collapse_shape
op to replace op
, or the collapse_shape
op will be completely replaced by the extract_slice
result. Either way, op
is replaced and the new op is returned.
can be transformed to
can be transformed to
This transform doesn't yet support reducing the rank of the reassociation indices, which would require inserting a tensor.expand_shape
op similar to the following example:
can be transformed to
Definition at line 160 of file ExtractSliceFromReshapeUtils.cpp.