MLIR
18.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... | |
Functions | |
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 | populateSimplifyTensorPack (RewritePatternSet &patterns) |
Patterns to simplify tensor.pack. 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... | |
std::unique_ptr< Pass > | createTensorBufferizePass () |
Creates an instance of the tensor dialect bufferization pass. More... | |
void | registerSubsetInsertionOpInterfaceExternalModels (DialectRegistry ®istry) |
FailureOr< TilingResult > | replaceExtractSliceWithTiledProducer (OpBuilder &builder, tensor::ExtractSliceOp sliceOp, OpResult producerOp) |
Pattern to swap an tensor.extract_slice with its producer when the producer 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 | populateFoldTensorEmptyPatterns (RewritePatternSet &patterns, bool foldSingleUseOnly=false) |
Populates patterns with patterns that fold tensor.empty with tensor. 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) |
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 type, Value source, Value pad, bool nofold, Location loc, OpBuilder &builder) |
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... | |
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)> |
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 477 of file TensorTilingInterfaceImpl.cpp.
References mlir::bindDims(), mlir::OpBuilder::create(), mlir::dispatchIndexOpFoldResults(), mlir::failure(), 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 106 of file IndependenceTransforms.cpp.
References mlir::OpBuilder::create(), mlir::failed(), mlir::failure(), 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 36 of file IndependenceTransforms.cpp.
References mlir::OpBuilder::create(), mlir::failed(), mlir::failure(), 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 275 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 305 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 57 of file Utils.cpp.
References mlir::applyPermutationToVector(), mlir::failure(), 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 2171 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 2519 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 43 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 256 of file FoldTensorSubsetOps.cpp.
PadOp mlir::tensor::createPadHighOp | ( | RankedTensorType | type, |
Value | source, | ||
Value | pad, | ||
bool | nofold, | ||
Location | loc, | ||
OpBuilder & | builder | ||
) |
Definition at line 24 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().
std::unique_ptr< Pass > mlir::tensor::createTensorBufferizePass | ( | ) |
Creates an instance of the tensor
dialect bufferization pass.
Definition at line 56 of file Bufferize.cpp.
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 314 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 50 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 60 of file TensorOps.cpp.
References getMixedSize(), and mlir::Value::getType().
Referenced by createCanonicalRankReducingExtractSliceOp(), createCanonicalRankReducingInsertSliceOp(), expandValue(), mlir::linalg::lowerPack(), mlir::linalg::lowerUnPack(), mlir::linalg::GeneralizeOuterUnitDimsPackOpPattern::matchAndRewrite(), mlir::linalg::GeneralizePadOpPattern::matchAndRewrite(), mlir::linalg::rewriteInDestinationPassingStyle(), and vectorizeAsTensorPadOp().
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 69 of file TensorOps.cpp.
References mlir::OpBuilder::create(), mlir::failed(), mlir::failure(), 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 104 of file TensorOps.cpp.
Referenced by tileAndFuseFirstExtractUseThroughContainingOpBlockArgument().
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 118 of file TensorOps.cpp.
void mlir::tensor::populateDropRedundantInsertSliceRankExpansionPatterns | ( | RewritePatternSet & | patterns | ) |
Populates patterns
with patterns that drop redundant tensor.insert_slice rank expansions.
Definition at line 147 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 2082 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 86 of file FoldIntoPackAndUnpackPatterns.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 tensor.
[extract_slice|expand_shape|collapse_shape].
If singleUseOnly
is set to "true", only tensor.empty ops with a single use are folded.
Definition at line 98 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 231 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 224 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 139 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 84 of file ReshapePatterns.cpp.
References mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::getContext().
void mlir::tensor::populateRewriteAsConstantPatterns | ( | RewritePatternSet & | patterns | ) |
Populates patterns
with patterns that replace tensor ops (such as tensor.generate) with constants when possible.
Definition at line 50 of file RewriteAsConstant.cpp.
References mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::getContext().
void mlir::tensor::populateSimplifyTensorPack | ( | RewritePatternSet & | patterns | ) |
Patterns to simplify tensor.pack.
Definition at line 3269 of file TensorOps.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 227 of file TensorOps.cpp.
Referenced by canFoldIntoConsumerOp(), and canFoldIntoProducerOp().
void mlir::tensor::registerBufferizableOpInterfaceExternalModels | ( | DialectRegistry & | registry | ) |
Definition at line 1027 of file BufferizableOpInterfaceImpl.cpp.
References mlir::DialectRegistry::addExtension(), mlir::MLIRContext::loadDialect(), and registerSubsetInsertionOpInterfaceExternalModels().
Referenced by mlir::registerAllDialects().
void mlir::tensor::registerFindPayloadReplacementOpInterfaceExternalModels | ( | DialectRegistry & | registry | ) |
Definition at line 69 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 206 of file TensorInferTypeOpInterfaceImpl.cpp.
References mlir::DialectRegistry::addExtension().
Referenced by mlir::registerAllDialects().
void mlir::tensor::registerSubsetInsertionOpInterfaceExternalModels | ( | DialectRegistry & | registry | ) |
Definition at line 124 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 687 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 696 of file TensorTilingInterfaceImpl.cpp.
References mlir::DialectRegistry::addExtension().
void mlir::tensor::registerTransformDialectExtension | ( | DialectRegistry & | registry | ) |
Definition at line 198 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 | ||
) |
Pattern 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::failed(), mlir::failure(), mlir::OpResult::getOwner(), and mlir::OpResult::getResultNumber().
Referenced by mlir::scf::tileAndFuseProducerOfSlice().
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.