MLIR  16.0.0git
Namespaces | Classes | Typedefs | Enumerations | Functions
mlir::vector Namespace Reference

Namespaces

 detail
 

Classes

struct  WarpExecuteOnLane0LoweringOptions
 
struct  VectorTransformsOptions
 Structure to control the behavior of vector transform patterns. More...
 
struct  UnrollVectorOptions
 Options that control the vector unrolling. More...
 
struct  VectorTransferFullPartialRewriter
 Apply splitFullAndPartialTransfer selectively via a pattern. More...
 
class  ContractionOpToMatmulOpLowering
 Progressive lowering of a vector.contract a, b, c with row-major matmul semantics to: More...
 
class  ContractionOpToOuterProductOpLowering
 Progressive lowering of a vector.contract a, b, c with row-major matmul semantics to a reduction_size-unrolled sequence: More...
 
class  ContractionOpToDotLowering
 Progressive lowering of a vector.contract a, b, c with row-major matmul semantics to an output-size-unrolled sequence: More...
 
class  ContractionOpLowering
 Progressive lowering of ContractionOp. More...
 

Typedefs

using DistributionMapFn = std::function< AffineMap(Value)>
 

Enumerations

enum class  BroadcastableToResult { Success = 0 , SourceRankHigher = 1 , DimensionMismatch = 2 , SourceTypeNotAVector = 3 }
 Return whether srcType can be broadcast to dstVectorType under the semantics of the vector.broadcast op. More...
 
enum class  VectorTransposeLowering { EltWise = 0 , Flat = 1 , Shuffle = 2 }
 Enum to control the lowering of vector.transpose operations. More...
 
enum class  VectorMultiReductionLowering { InnerParallel = 0 , InnerReduction = 1 }
 Enum to control the lowering of vector.multi_reduction operations. More...
 
enum class  VectorContractLowering { Dot = 0 , Matmul = 1 , OuterProduct = 2 , ParallelArith = 3 }
 Enum to control the lowering of vector.contract operations. More...
 
enum class  VectorTransferSplit { None = 0 , VectorTransfer = 1 , LinalgCopy = 2 , ForceInBounds = 3 }
 Enum to control the splitting of vector.transfer operations into in-bounds and out-of-bounds variants. More...
 

Functions

void buildTerminatedBody (OpBuilder &builder, Location loc)
 Default callback to build a region with a 'vector.yield' terminator with no arguments. More...
 
BroadcastableToResult isBroadcastableTo (Type srcType, VectorType dstVectorType, std::pair< int, int > *mismatchingDims=nullptr)
 
void populateVectorToVectorCanonicalizationPatterns (RewritePatternSet &patterns, PatternBenefit benefit=1)
 Collect a set of vector-to-vector canonicalization patterns. More...
 
void populateShapeCastFoldingPatterns (RewritePatternSet &patterns, PatternBenefit benefit=1)
 Collect a set of vector.shape_cast folding patterns. More...
 
void populateCastAwayVectorLeadingOneDimPatterns (RewritePatternSet &patterns, PatternBenefit benefit=1)
 Collect a set of leading one dimension removal patterns. More...
 
void populateVectorTransferDropUnitDimsPatterns (RewritePatternSet &patterns, PatternBenefit benefit=1)
 Collect a set of one dimension removal patterns. More...
 
void populateFlattenVectorTransferPatterns (RewritePatternSet &patterns, PatternBenefit benefit=1)
 Collect a set of patterns to flatten n-D vector transfers on contiguous memref. More...
 
void populateBubbleVectorBitCastOpPatterns (RewritePatternSet &patterns, PatternBenefit benefit=1)
 Collect a set of patterns that bubble up/down bitcast ops. More...
 
void populateVectorTransferLoweringPatterns (RewritePatternSet &patterns, llvm::Optional< unsigned > maxTransferRank=llvm::None, PatternBenefit benefit=1)
 Collect a set of transfer read/write lowering patterns. More...
 
void populateVectorMaskMaterializationPatterns (RewritePatternSet &patterns, bool force32BitVectorIndices, PatternBenefit benefit=1)
 These patterns materialize masks for various vector ops such as transfers. More...
 
void populateVectorBroadcastLoweringPatterns (RewritePatternSet &patterns, PatternBenefit benefit=1)
 Collects patterns to progressively lower vector.broadcast ops on high-D vectors to low-D vector ops. More...
 
void populateVectorMaskOpLoweringPatterns (RewritePatternSet &patterns, PatternBenefit benefit=1)
 Collects patterns to progressively lower vector mask ops into elementary selection and insertion ops. More...
 
void populateVectorShapeCastLoweringPatterns (RewritePatternSet &patterns, PatternBenefit benefit=1)
 Collects patterns to progressively lower vector.shape_cast ops on high-D vectors into 1-D/2-D vector ops by generating data movement extract/insert ops. More...
 
IntegerType getVectorSubscriptType (Builder &builder)
 Returns the integer type required for subscripts in the vector dialect. More...
 
ArrayAttr getVectorSubscriptAttr (Builder &b, ArrayRef< int64_t > values)
 Returns an integer array attribute containing the given values using the integer type required for subscripts in the vector dialect. More...
 
Value getVectorReductionOp (arith::AtomicRMWKind op, OpBuilder &builder, Location loc, Value vector)
 Returns the value obtained by reducing the vector into a scalar using the operation kind associated with a binary AtomicRMWKind op. More...
 
bool isLastMemrefDimUnitStride (MemRefType type)
 Return true if the last dimension of the MemRefType has unit stride. More...
 
AffineMap getTransferMinorIdentityMap (ShapedType shapedType, VectorType vectorType)
 Build the default minor identity map suitable for a vector transfer. More...
 
bool checkSameValueRAW (TransferWriteOp defWrite, TransferReadOp read)
 Return true if the transfer_write fully writes the data accessed by the transfer_read. More...
 
bool checkSameValueWAW (TransferWriteOp write, TransferWriteOp priorWrite)
 Return true if the write op fully over-write the priorWrite transfer_write op. More...
 
bool isDisjointTransferIndices (VectorTransferOpInterface transferA, VectorTransferOpInterface transferB)
 Same behavior as isDisjointTransferSet but doesn't require the operations to have the same tensor/memref. More...
 
bool isDisjointTransferSet (VectorTransferOpInterface transferA, VectorTransferOpInterface transferB)
 Return true if we can prove that the transfer operations access disjoint memory. More...
 
Value makeArithReduction (OpBuilder &b, Location loc, CombiningKind kind, Value v1, Value v2)
 Return the result value of reducing two scalar/vector values with the corresponding arith operation. More...
 
bool isParallelIterator (Attribute attr)
 Returns true if attr has "parallel" iterator type semantics. More...
 
bool isReductionIterator (Attribute attr)
 Returns true if attr has "reduction" iterator type semantics. More...
 
void registerTransformDialectExtension (DialectRegistry &registry)
 
void registerBufferizableOpInterfaceExternalModels (DialectRegistry &registry)
 
std::unique_ptr< PasscreateVectorBufferizePass ()
 Creates an instance of the vector dialect bufferization pass. More...
 
std::unique_ptr< PasscreateLowerVectorMaskPass ()
 Creates an instance of the vector.mask lowering pass. More...
 
void populateWarpExecuteOnLane0OpToScfForPattern (RewritePatternSet &patterns, const WarpExecuteOnLane0LoweringOptions &options, PatternBenefit benefit=1)
 
void populateVectorTransposeLoweringPatterns (RewritePatternSet &patterns, VectorTransformsOptions options=VectorTransformsOptions(), PatternBenefit benefit=1)
 Insert TransposeLowering patterns into extraction/insertion. More...
 
void populateVectorMultiReductionLoweringPatterns (RewritePatternSet &patterns, VectorMultiReductionLowering options, PatternBenefit benefit=1)
 Collect a set of patterns to convert vector.multi_reduction op into a sequence of vector.reduction ops. More...
 
void populateVectorContractLoweringPatterns (RewritePatternSet &patterns, VectorTransformsOptions options=VectorTransformsOptions(), PatternBenefit benefit=1)
 Collects patterns to progressively lower vector contraction ops on high-D into low-D reduction and product ops. More...
 
void populateVectorReductionToContractPatterns (RewritePatternSet &patterns, PatternBenefit benefit=1)
 Collect patterns to convert reduction op to vector.contract and fold transpose/broadcast ops into the contract. More...
 
void populateVectorScanLoweringPatterns (RewritePatternSet &patterns, PatternBenefit benefit=1)
 Collect patterns to convert scan op. More...
 
void populateVectorTransferPermutationMapLoweringPatterns (RewritePatternSet &patterns, PatternBenefit benefit=1)
 Collect a set of transfer read/write lowering patterns that simplify the permutation map (e.g., converting it to a minor identity map) by inserting broadcasts and transposes. More...
 
void populateVectorTransferCollapseInnerMostContiguousDimsPatterns (RewritePatternSet &patterns, PatternBenefit benefit=1)
 Collect a set of patterns to reduce the rank of the operands of vector transfer ops to operate on the largest contigious vector. More...
 
void populateVectorInsertExtractStridedSliceDecompositionPatterns (RewritePatternSet &patterns, PatternBenefit benefit=1)
 Populate patterns with the following patterns. More...
 
void populateVectorExtractStridedSliceToExtractInsertChainPatterns (RewritePatternSet &patterns, std::function< bool(ExtractStridedSliceOp)> controlFn=nullptr, PatternBenefit benefit=1)
 Populate patterns with a pattern to breaks down 1-D extract_strided_slice ops into a chain of Extract ops to extract each element from the source, and then a chain of Insert ops to insert to the target vector. More...
 
void populateVectorInsertExtractStridedSliceTransforms (RewritePatternSet &patterns, PatternBenefit benefit=1)
 Populate patterns with the following patterns. More...
 
void populateVectorUnrollPatterns (RewritePatternSet &patterns, const UnrollVectorOptions &options, PatternBenefit benefit=1)
 Collect a set of pattern to unroll vector operations to a smaller shapes. More...
 
LogicalResult splitFullAndPartialTransfer (RewriterBase &b, VectorTransferOpInterface xferOp, VectorTransformsOptions options=VectorTransformsOptions(), scf::IfOp *ifOp=nullptr)
 Split a vector.transfer operation into an in-bounds (i.e., no out-of-bounds masking) fastpath and a slowpath. More...
 
void transferOpflowOpt (Operation *rootOp)
 Implements transfer op write to read forwarding and dead transfer write optimizations. More...
 
Value createOrFoldDimOp (OpBuilder &b, Location loc, Value source, int64_t dim)
 Helper function that creates a memref::DimOp or tensor::DimOp depending on the type of source. More...
 

Typedef Documentation

◆ DistributionMapFn

using mlir::vector::DistributionMapFn = typedef std::function<AffineMap(Value)>

Definition at line 43 of file VectorDistribution.h.

Enumeration Type Documentation

◆ BroadcastableToResult

Return whether srcType can be broadcast to dstVectorType under the semantics of the vector.broadcast op.

Enumerator
Success 
SourceRankHigher 
DimensionMismatch 
SourceTypeNotAVector 

Definition at line 61 of file VectorOps.h.

◆ VectorContractLowering

Enum to control the lowering of vector.contract operations.

Enumerator
Dot 

Progressively lower to finer grained vector.contract and dot-products.

Matmul 

Lower to vector.matrix_multiply, maps 1-1 to LLVM matrix intrinsics.

OuterProduct 

Lower to vector.outerproduct.

ParallelArith 

Lower contract with all reduction dimensions unrolled to 1 to a vector elementwise operations.

Definition at line 45 of file VectorRewritePatterns.h.

◆ VectorMultiReductionLowering

Enum to control the lowering of vector.multi_reduction operations.

Enumerator
InnerParallel 

Lower multi_reduction into outer-reduction and inner-parallel ops.

InnerReduction 

Lower multi_reduction into outer-parallel and inner-reduction ops.

Definition at line 38 of file VectorRewritePatterns.h.

◆ VectorTransferSplit

Enum to control the splitting of vector.transfer operations into in-bounds and out-of-bounds variants.

Enumerator
None 

Do not split vector transfer operations.

VectorTransfer 

Split using in-bounds + out-of-bounds vector.transfer operations.

LinalgCopy 

Split using an in-bounds vector.transfer + linalg.fill + linalg.copy operations.

ForceInBounds 

Do not split vector transfer operation but instead mark it as "in-bounds".

Definition at line 58 of file VectorRewritePatterns.h.

◆ VectorTransposeLowering

Enum to control the lowering of vector.transpose operations.

Enumerator
EltWise 

Lower transpose into element-wise extract and inserts.

Flat 

Lower 2-D transpose to vector.flat_transpose, maps 1-1 to LLVM matrix intrinsics.

Shuffle 

Lower 2-D transpose to vector.shuffle.

Definition at line 28 of file VectorRewritePatterns.h.

Function Documentation

◆ buildTerminatedBody()

void mlir::vector::buildTerminatedBody ( OpBuilder builder,
Location  loc 
)

Default callback to build a region with a 'vector.yield' terminator with no arguments.

Definition at line 106 of file VectorOps.cpp.

References mlir::OpBuilder::create().

◆ checkSameValueRAW()

bool mlir::vector::checkSameValueRAW ( TransferWriteOp  defWrite,
TransferReadOp  read 
)

Return true if the transfer_write fully writes the data accessed by the transfer_read.

◆ checkSameValueWAW()

bool mlir::vector::checkSameValueWAW ( TransferWriteOp  write,
TransferWriteOp  priorWrite 
)

Return true if the write op fully over-write the priorWrite transfer_write op.

◆ createLowerVectorMaskPass()

std::unique_ptr< Pass > mlir::vector::createLowerVectorMaskPass ( )

Creates an instance of the vector.mask lowering pass.

Definition at line 144 of file LowerVectorMask.cpp.

◆ createOrFoldDimOp()

Value mlir::vector::createOrFoldDimOp ( OpBuilder b,
Location  loc,
Value  source,
int64_t  dim 
)

Helper function that creates a memref::DimOp or tensor::DimOp depending on the type of source.

Definition at line 37 of file VectorUtils.cpp.

References mlir::OpBuilder::createOrFold(), mlir::Value::getType(), and mlir::Type::isa().

Referenced by createInBoundsCond(), createSubViewIntersection(), and MaterializeTransferMask< ConcreteOp >::matchAndRewrite().

◆ createVectorBufferizePass()

std::unique_ptr< Pass > mlir::vector::createVectorBufferizePass ( )

Creates an instance of the vector dialect bufferization pass.

Definition at line 53 of file Bufferize.cpp.

◆ getTransferMinorIdentityMap()

AffineMap mlir::vector::getTransferMinorIdentityMap ( ShapedType  shapedType,
VectorType  vectorType 
)

Build the default minor identity map suitable for a vector transfer.

This also handles the case memref<... x vector<...>> -> vector<...> in which the rank of the identity map must take the vector element type into account.

Definition at line 141 of file VectorOps.cpp.

References mlir::AffineMap::get(), mlir::getAffineConstantExpr(), and mlir::AffineMap::getMinorIdentityMap().

◆ getVectorReductionOp()

Value mlir::vector::getVectorReductionOp ( arith::AtomicRMWKind  op,
OpBuilder builder,
Location  loc,
Value  vector 
)

Returns the value obtained by reducing the vector into a scalar using the operation kind associated with a binary AtomicRMWKind op.

Definition at line 429 of file VectorOps.cpp.

References mlir::OpBuilder::create(), mlir::emitOptionalError(), and mlir::Value::getLoc().

◆ getVectorSubscriptAttr()

ArrayAttr mlir::vector::getVectorSubscriptAttr ( Builder b,
ArrayRef< int64_t >  values 
)

Returns an integer array attribute containing the given values using the integer type required for subscripts in the vector dialect.

Definition at line 269 of file VectorOps.cpp.

References mlir::Builder::getI64ArrayAttr().

◆ getVectorSubscriptType()

IntegerType mlir::vector::getVectorSubscriptType ( Builder builder)

Returns the integer type required for subscripts in the vector dialect.

Definition at line 265 of file VectorOps.cpp.

References mlir::Builder::getIntegerType().

◆ isBroadcastableTo()

BroadcastableToResult mlir::vector::isBroadcastableTo ( Type  srcType,
VectorType  dstVectorType,
std::pair< int, int > *  mismatchingDims = nullptr 
)

◆ isDisjointTransferIndices()

bool mlir::vector::isDisjointTransferIndices ( VectorTransferOpInterface  transferA,
VectorTransferOpInterface  transferB 
)

Same behavior as isDisjointTransferSet but doesn't require the operations to have the same tensor/memref.

This allows comparing operations accessing different tensors.

Definition at line 176 of file VectorOps.cpp.

References mlir::presburger::abs().

Referenced by findMatchingTransferRead(), isDisjointTransferSet(), and tensorChunkAccessedByUnknownOp().

◆ isDisjointTransferSet()

bool mlir::vector::isDisjointTransferSet ( VectorTransferOpInterface  transferA,
VectorTransferOpInterface  transferB 
)

Return true if we can prove that the transfer operations access disjoint memory.

Definition at line 208 of file VectorOps.cpp.

References isDisjointTransferIndices().

Referenced by mlir::linalg::hoistRedundantVectorTransfers().

◆ isLastMemrefDimUnitStride()

bool mlir::vector::isLastMemrefDimUnitStride ( MemRefType  type)

Return true if the last dimension of the MemRefType has unit stride.

Also return true for memrefs with no strides.

Definition at line 134 of file VectorOps.cpp.

References mlir::getStridesAndOffset(), and mlir::succeeded().

Referenced by TransferReadToVectorLoadLowering::matchAndRewrite(), and TransferWriteToVectorStoreLowering::matchAndRewrite().

◆ isParallelIterator()

bool mlir::vector::isParallelIterator ( Attribute  attr)
inline

Returns true if attr has "parallel" iterator type semantics.

Definition at line 192 of file VectorOps.h.

References mlir::Attribute::cast().

Referenced by contractSupportsMMAMatrixType(), and mlir::vector::ContractionOpToMatmulOpLowering::matchAndRewrite().

◆ isReductionIterator()

bool mlir::vector::isReductionIterator ( Attribute  attr)
inline

Returns true if attr has "reduction" iterator type semantics.

Definition at line 197 of file VectorOps.h.

References mlir::Attribute::cast().

Referenced by contractSupportsMMAMatrixType(), getReductionIndex(), and mlir::vector::ContractionOpToMatmulOpLowering::matchAndRewrite().

◆ makeArithReduction()

Value mlir::vector::makeArithReduction ( OpBuilder b,
Location  loc,
CombiningKind  kind,
Value  v1,
Value  v2 
)

Return the result value of reducing two scalar/vector values with the corresponding arith operation.

Referenced by TwoDimMultiReductionToElementWise::matchAndRewrite().

◆ populateBubbleVectorBitCastOpPatterns()

void mlir::vector::populateBubbleVectorBitCastOpPatterns ( RewritePatternSet patterns,
PatternBenefit  benefit = 1 
)

Collect a set of patterns that bubble up/down bitcast ops.

These patterns move vector.bitcast ops to be before insert ops or after extract ops where suitable. With them, bitcast will happen on smaller vectors and there are more chances to share extract/insert ops.

Definition at line 2973 of file VectorTransforms.cpp.

References mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::getContext().

◆ populateCastAwayVectorLeadingOneDimPatterns()

void mlir::vector::populateCastAwayVectorLeadingOneDimPatterns ( RewritePatternSet patterns,
PatternBenefit  benefit = 1 
)

Collect a set of leading one dimension removal patterns.

These patterns insert vector.shape_cast to remove leading one dimensions to expose more canonical forms of read/write/insert/extract operations. With them, there are more chances that we can cancel out extract-insert pairs or forward write-read pairs.

Definition at line 439 of file VectorDropLeadUnitDim.cpp.

References mlir::RewritePatternSet::add(), mlir::RewritePatternSet::getContext(), and populateShapeCastFoldingPatterns().

◆ populateFlattenVectorTransferPatterns()

void mlir::vector::populateFlattenVectorTransferPatterns ( RewritePatternSet patterns,
PatternBenefit  benefit = 1 
)

Collect a set of patterns to flatten n-D vector transfers on contiguous memref.

These patterns insert memref.collapse_shape + vector.shape_cast patterns to transform multiple small n-D transfers into a larger 1-D transfer where the memref contiguity properties allow it.

Definition at line 585 of file VectorTransferOpTransforms.cpp.

References mlir::RewritePatternSet::add(), mlir::RewritePatternSet::getContext(), and populateShapeCastFoldingPatterns().

◆ populateShapeCastFoldingPatterns()

void mlir::vector::populateShapeCastFoldingPatterns ( RewritePatternSet patterns,
PatternBenefit  benefit = 1 
)

◆ populateVectorBroadcastLoweringPatterns()

void mlir::vector::populateVectorBroadcastLoweringPatterns ( RewritePatternSet patterns,
PatternBenefit  benefit = 1 
)

Collects patterns to progressively lower vector.broadcast ops on high-D vectors to low-D vector ops.

Definition at line 2981 of file VectorTransforms.cpp.

References mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::getContext().

◆ populateVectorContractLoweringPatterns()

void mlir::vector::populateVectorContractLoweringPatterns ( RewritePatternSet patterns,
VectorTransformsOptions  options = VectorTransformsOptions(),
PatternBenefit  benefit = 1 
)

Collects patterns to progressively lower vector contraction ops on high-D into low-D reduction and product ops.

Definition at line 2999 of file VectorTransforms.cpp.

References mlir::RewritePatternSet::add(), mlir::RewritePatternSet::getContext(), and options.

◆ populateVectorExtractStridedSliceToExtractInsertChainPatterns()

void mlir::vector::populateVectorExtractStridedSliceToExtractInsertChainPatterns ( RewritePatternSet patterns,
std::function< bool(ExtractStridedSliceOp)>  controlFn = nullptr,
PatternBenefit  benefit = 1 
)

Populate patterns with a pattern to breaks down 1-D extract_strided_slice ops into a chain of Extract ops to extract each element from the source, and then a chain of Insert ops to insert to the target vector.

If controlFn is not nullptr, the pattern will only be invoked on ops that controlFn returns true. Otherwise runs on ops.

Definition at line 342 of file VectorInsertExtractStridedSliceRewritePatterns.cpp.

References mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::getContext().

◆ populateVectorInsertExtractStridedSliceDecompositionPatterns()

void mlir::vector::populateVectorInsertExtractStridedSliceDecompositionPatterns ( RewritePatternSet patterns,
PatternBenefit  benefit = 1 
)

Populate patterns with the following patterns.

[DecomposeDifferentRankInsertStridedSlice]

RewritePattern for InsertStridedSliceOp where source and destination vectors have different ranks.

When ranks are different, InsertStridedSlice needs to extract a properly ranked vector from the destination vector into which to insert. This pattern only takes care of this extraction part and forwards the rest to [VectorInsertStridedSliceOpSameRankRewritePattern].

For a k-D source and n-D destination vector (k < n), we emit:

  1. ExtractOp to extract the (unique) (n-1)-D subvector into which to insert the k-D source.
  2. k-D -> (n-1)-D InsertStridedSlice op
  3. InsertOp that is the reverse of 1.

[DecomposeNDExtractStridedSlice]

For such cases, we can rewrite it to ExtractOp/ExtractElementOp + lower rank ExtractStridedSliceOp + InsertOp/InsertElementOp for the n-D case.

Definition at line 336 of file VectorInsertExtractStridedSliceRewritePatterns.cpp.

References mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::getContext().

Referenced by populateVectorInsertExtractStridedSliceTransforms().

◆ populateVectorInsertExtractStridedSliceTransforms()

void mlir::vector::populateVectorInsertExtractStridedSliceTransforms ( RewritePatternSet patterns,
PatternBenefit  benefit = 1 
)

Populate patterns with the following patterns.

Populate the given list with patterns that convert from Vector to LLVM.

Patterns in populateVectorInsertExtractStridedSliceDecompositionPatterns();

[ConvertSameRankInsertStridedSliceIntoShuffle]

RewritePattern for InsertStridedSliceOp where source and destination vectors have the same rank. For each outermost index in the slice: begin end stride [offset : offset+size*stride : stride]

  1. ExtractOp one (k-1)-D source subvector and one (n-1)-D dest subvector.
  2. InsertStridedSlice (k-1)-D into (n-1)-D
  3. the destination subvector is inserted back in the proper place
  1. InsertOp that is the reverse of 1.

[Convert1DExtractStridedSliceIntoShuffle]

For such cases, we can lower it to a ShuffleOp.

Definition at line 351 of file VectorInsertExtractStridedSliceRewritePatterns.cpp.

References mlir::RewritePatternSet::add(), mlir::RewritePatternSet::getContext(), and populateVectorInsertExtractStridedSliceDecompositionPatterns().

Referenced by mlir::populateVectorToLLVMConversionPatterns().

◆ populateVectorMaskMaterializationPatterns()

void mlir::vector::populateVectorMaskMaterializationPatterns ( RewritePatternSet patterns,
bool  force32BitVectorIndices,
PatternBenefit  benefit = 1 
)

These patterns materialize masks for various vector ops such as transfers.

Definition at line 2959 of file VectorTransforms.cpp.

References mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::getContext().

◆ populateVectorMaskOpLoweringPatterns()

void mlir::vector::populateVectorMaskOpLoweringPatterns ( RewritePatternSet patterns,
PatternBenefit  benefit = 1 
)

Collects patterns to progressively lower vector mask ops into elementary selection and insertion ops.

Definition at line 2986 of file VectorTransforms.cpp.

References mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::getContext().

◆ populateVectorMultiReductionLoweringPatterns()

void mlir::vector::populateVectorMultiReductionLoweringPatterns ( RewritePatternSet patterns,
VectorMultiReductionLowering  options,
PatternBenefit  benefit = 1 
)

Collect a set of patterns to convert vector.multi_reduction op into a sequence of vector.reduction ops.

The patterns comprise:

  • InnerOuterDimReductionConversion: rewrites vector.multi_reduction such that all reduction dimensions are either innermost or outermost, by adding the proper vector.transpose operations.
  • ReduceMultiDimReductionRank: once in innermost or outermost reduction form, rewrites n-D vector.multi_reduction into 2-D vector.multi_reduction, by introducing vector.shape_cast ops to collapse + multi-reduce + expand back.
  • TwoDimMultiReductionToElementWise: once in 2-D vector.multi_reduction form, with an outermost reduction dimension, unroll the outer dimension to obtain a sequence of 1-D vector ops. This also has an opportunity for tree-reduction (in the future).
  • TwoDimMultiReductionToReduction: once in 2-D vector.multi_reduction form, with an innermost reduction dimension, unroll the outer dimension to obtain a sequence of extract + vector.reduction + insert. This can further lower to horizontal reduction ops.
  • OneDimMultiReductionToTwoDim: for cases that reduce to 1-D vector<k> reduction (and are thus missing either a parallel or a reduction), we lift them back up to 2-D with a simple vector.shape_cast to vector<1xk> so that the other patterns can kick in, thus fully exiting out of the vector.multi_reduction abstraction.

Definition at line 342 of file VectorMultiDimReductionTransforms.cpp.

References mlir::RewritePatternSet::add(), mlir::RewritePatternSet::getContext(), and options.

◆ populateVectorReductionToContractPatterns()

void mlir::vector::populateVectorReductionToContractPatterns ( RewritePatternSet patterns,
PatternBenefit  benefit = 1 
)

Collect patterns to convert reduction op to vector.contract and fold transpose/broadcast ops into the contract.

Definition at line 3015 of file VectorTransforms.cpp.

References mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::getContext().

◆ populateVectorScanLoweringPatterns()

void mlir::vector::populateVectorScanLoweringPatterns ( RewritePatternSet patterns,
PatternBenefit  benefit = 1 
)

Collect patterns to convert scan op.

Definition at line 3040 of file VectorTransforms.cpp.

References mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::getContext().

◆ populateVectorShapeCastLoweringPatterns()

void mlir::vector::populateVectorShapeCastLoweringPatterns ( RewritePatternSet patterns,
PatternBenefit  benefit = 1 
)

Collects patterns to progressively lower vector.shape_cast ops on high-D vectors into 1-D/2-D vector ops by generating data movement extract/insert ops.

Definition at line 2992 of file VectorTransforms.cpp.

References mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::getContext().

◆ populateVectorToVectorCanonicalizationPatterns()

void mlir::vector::populateVectorToVectorCanonicalizationPatterns ( RewritePatternSet patterns,
PatternBenefit  benefit = 1 
)

Collect a set of vector-to-vector canonicalization patterns.

◆ populateVectorTransferCollapseInnerMostContiguousDimsPatterns()

void mlir::vector::populateVectorTransferCollapseInnerMostContiguousDimsPatterns ( RewritePatternSet patterns,
PatternBenefit  benefit = 1 
)

Collect a set of patterns to reduce the rank of the operands of vector transfer ops to operate on the largest contigious vector.

These patterns are useful when lowering to dialects with 1d vector type such as llvm and it will result fewer memory reads.

Definition at line 3023 of file VectorTransforms.cpp.

References mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::getContext().

◆ populateVectorTransferDropUnitDimsPatterns()

void mlir::vector::populateVectorTransferDropUnitDimsPatterns ( RewritePatternSet patterns,
PatternBenefit  benefit = 1 
)

Collect a set of one dimension removal patterns.

These patterns insert rank-reducing memref.subview ops to remove one dimensions. With them, there are more chances that we can avoid potentially exensive vector.shape_cast operations.

Definition at line 577 of file VectorTransferOpTransforms.cpp.

References mlir::RewritePatternSet::add(), mlir::RewritePatternSet::getContext(), and populateShapeCastFoldingPatterns().

◆ populateVectorTransferLoweringPatterns()

void mlir::vector::populateVectorTransferLoweringPatterns ( RewritePatternSet patterns,
llvm::Optional< unsigned >  maxTransferRank = llvm::None,
PatternBenefit  benefit = 1 
)

Collect a set of transfer read/write lowering patterns.

These patterns lower transfer ops to simpler ops like vector.load, vector.store and vector.broadcast. Only transfers with a transfer rank of a most maxTransferRank are lowered. This is useful when combined with VectorToSCF, which reduces the rank of vector transfer ops.

Definition at line 3029 of file VectorTransforms.cpp.

References mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::getContext().

Referenced by mlir::populateVectorToLLVMConversionPatterns().

◆ populateVectorTransferPermutationMapLoweringPatterns()

void mlir::vector::populateVectorTransferPermutationMapLoweringPatterns ( RewritePatternSet patterns,
PatternBenefit  benefit = 1 
)

Collect a set of transfer read/write lowering patterns that simplify the permutation map (e.g., converting it to a minor identity map) by inserting broadcasts and transposes.

More specifically:

[TransferReadPermutationLowering] Lower transfer_read op with permutation into a transfer_read with a permutation map composed of leading zeros followed by a minor identity + vector.transpose op. Ex: vector.transfer_read ... permutation_map: (d0, d1, d2) -> (0, d1) into: v = vector.transfer_read ... permutation_map: (d0, d1, d2) -> (d1, 0) vector.transpose v, [1, 0]

vector.transfer_read ... permutation_map: (d0, d1, d2, d3) -> (0, 0, 0, d1, d3) into: v = vector.transfer_read ... permutation_map: (d0, d1, d2, d3) -> (0, 0, d1, 0, d3) vector.transpose v, [0, 1, 3, 2, 4] Note that an alternative is to transform it to linalg.transpose + vector.transfer_read to do the transpose in memory instead.

[TransferWritePermutationLowering] Lower transfer_write op with permutation into a transfer_write with a minor identity permutation map. (transfer_write ops cannot have broadcasts.) Ex: vector.transfer_write v ... permutation_map: (d0, d1, d2) -> (d2, d0, d1) into: tmp = vector.transpose v, [2, 0, 1] vector.transfer_write tmp ... permutation_map: (d0, d1, d2) -> (d0, d1, d2)

vector.transfer_write v ... permutation_map: (d0, d1, d2, d3) -> (d3, d2) into: tmp = vector.transpose v, [1, 0] v = vector.transfer_write tmp ... permutation_map: (d0, d1, d2, d3) -> (d2, d3)

[TransferOpReduceRank] Lower transfer_read op with broadcast in the leading dimensions into transfer_read of lower rank + vector.broadcast. Ex: vector.transfer_read ... permutation_map: (d0, d1, d2, d3) -> (0, d1, 0, d3) into: v = vector.transfer_read ... permutation_map: (d0, d1, d2, d3) -> (d1, 0, d3) vector.broadcast v

Definition at line 273 of file VectorTransferPermutationMapRewritePatterns.cpp.

References mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::getContext().

◆ populateVectorTransposeLoweringPatterns()

void mlir::vector::populateVectorTransposeLoweringPatterns ( RewritePatternSet patterns,
VectorTransformsOptions  options = VectorTransformsOptions(),
PatternBenefit  benefit = 1 
)

Insert TransposeLowering patterns into extraction/insertion.

Definition at line 3008 of file VectorTransforms.cpp.

References mlir::RewritePatternSet::add(), mlir::RewritePatternSet::getContext(), and options.

◆ populateVectorUnrollPatterns()

void mlir::vector::populateVectorUnrollPatterns ( RewritePatternSet patterns,
const UnrollVectorOptions options,
PatternBenefit  benefit = 1 
)

Collect a set of pattern to unroll vector operations to a smaller shapes.

options structure controls which operations are unrolled and the target shape. op is unrolled to the targetShape as follows, for each of its operands:

  1. the unrolled type unrolledVectorType and number of unrolled instances numUnrolledInstances are computed from the targetShape. For now it is assumed the unrolling factors divide the vector sizes.
  2. ExtractStridedSlice are created to break-up the vector operands.
  3. the original op is cloned numUnrolledInstances times, once for each result.
  4. InsertStridedSlice are inserted to re-assemble the slices into the original vectore shape.

Example:

opA(operand0, operand1) // numUnrolledInstances = 3

    operand0                   operand1
       |                          |
     fork                       fork
<----------gather all fork ops --------->
      /|\                        /|\
  f00 f01 f02                f10 f11 f12
<---------- clone op 3 times --------->
  opA0(f00, f10), opA1(f01, f11), opA2(f02, f12)
         \            |            /

<-----------------— join ----------------------—>

Other local patterns then kick in iteratively (including DCE) and compose to combine the ExtractStridedSlice/InsertStridedSlice.

Definition at line 650 of file VectorUnroll.cpp.

References mlir::RewritePatternSet::add(), mlir::RewritePatternSet::getContext(), and options.

◆ populateWarpExecuteOnLane0OpToScfForPattern()

void mlir::vector::populateWarpExecuteOnLane0OpToScfForPattern ( RewritePatternSet patterns,
const WarpExecuteOnLane0LoweringOptions options,
PatternBenefit  benefit = 1 
)

◆ registerBufferizableOpInterfaceExternalModels()

void mlir::vector::registerBufferizableOpInterfaceExternalModels ( DialectRegistry registry)

◆ registerTransformDialectExtension()

void mlir::vector::registerTransformDialectExtension ( DialectRegistry registry)

Definition at line 173 of file VectorTransformOps.cpp.

References mlir::DialectRegistry::addExtensions().

Referenced by mlir::registerAllDialects().

◆ splitFullAndPartialTransfer()

LogicalResult mlir::vector::splitFullAndPartialTransfer ( RewriterBase b,
VectorTransferOpInterface  xferOp,
VectorTransformsOptions  options = VectorTransformsOptions(),
scf::IfOp *  ifOp = nullptr 
)

Split a vector.transfer operation into an in-bounds (i.e., no out-of-bounds masking) fastpath and a slowpath.

If ifOp is not null and the result is success, theifOp` points to the newly created conditional upon function return. To accomodate for the fact that the original vector.transfer indexing may be arbitrary and the slow path indexes @[0...0] in the temporary buffer, the scf.if op returns a view and values of type index. At this time, only vector.transfer_read case is implemented.

Example (a 2-D vector.transfer_read): ``` %1 = vector.transfer_read %0[...], pad : memref<A...>, vector<...> ``` is transformed into: ``` %1:3 = scf.if (inBounds) { // fastpath, direct cast memref.cast A: memref<A...> to compatibleMemRefType scf.yield view : compatibleMemRefType, index, index } else { // slowpath, not in-bounds vector.transfer or linalg.copy. memref.cast alloc: memref<B...> to compatibleMemRefType scf.yield %4 : compatibleMemRefType, index, index */ // } /** %0 = vector.transfer_read %1#0[%1#1, %1#2] {in_bounds = [true ... true]} `` wherealloc` is a top of the function alloca'ed buffer of one vector.

Preconditions:

  1. xferOp.permutation_map() must be a minor identity map
  2. the rank of the xferOp.memref() and the rank of the xferOp.vector() must be equal. This will be relaxed in the future but requires rank-reducing subviews.

For vector.transfer_read: If ifOp is not null and the result is success, theifOp` points to the newly created conditional upon function return. To accomodate for the fact that the original vector.transfer indexing may be arbitrary and the slow path indexes @[0...0] in the temporary buffer, the scf.if op returns a view and values of type index.

Example (a 2-D vector.transfer_read): ``` %1 = vector.transfer_read %0[...], pad : memref<A...>, vector<...> ``` is transformed into: ``` %1:3 = scf.if (inBounds) { // fastpath, direct cast memref.cast A: memref<A...> to compatibleMemRefType scf.yield view : compatibleMemRefType, index, index } else { // slowpath, not in-bounds vector.transfer or linalg.copy. memref.cast alloc: memref<B...> to compatibleMemRefType scf.yield %4 : compatibleMemRefType, index, index */ // } /** %0 = vector.transfer_read %1#0[%1#1, %1#2] {in_bounds = [true ... true]} `` wherealloc` is a top of the function alloca'ed buffer of one vector.

For vector.transfer_write: There are 2 conditional blocks. First a block to decide which memref and indices to use for an unmasked, inbounds write. Then a conditional block to further copy a partial buffer into the final result in the slow path case.

Example (a 2-D vector.transfer_write): ``` vector.transfer_write arg, %0[...], pad : memref<A...>, vector<...> ``` is transformed into: ``` %1:3 = scf.if (inBounds) { memref.cast A: memref<A...> to compatibleMemRefType scf.yield view : compatibleMemRefType, index, index } else { memref.cast alloc: memref<B...> to compatibleMemRefType scf.yield %4 : compatibleMemRefType, index, index } %0 = vector.transfer_write arg, %1#0[%1#1, %1#2] {in_bounds = [true ... true]} scf.if (notInBounds) { // slowpath: not in-bounds vector.transfer or linalg.copy. } `` wherealloc` is a top of the function alloca'ed buffer of one vector.

Preconditions:

  1. xferOp.permutation_map() must be a minor identity map
  2. the rank of the xferOp.source() and the rank of the xferOp.vector() must be equal. This will be relaxed in the future but requires rank-reducing subviews.

Definition at line 519 of file VectorTransferSplitRewritePatterns.cpp.

References mlir::Type::cast(), mlir::clone(), mlir::OpBuilder::clone(), mlir::OpBuilder::create(), createFullPartialLinalgCopy(), createFullPartialVectorTransferRead(), createFullPartialVectorTransferWrite(), createInBoundsCond(), mlir::RewriterBase::eraseOp(), mlir::failure(), ForceInBounds, mlir::Region::front(), getAutomaticAllocationScope(), mlir::Builder::getBoolArrayAttr(), getCastCompatibleMemRefType(), mlir::Builder::getI64IntegerAttr(), mlir::Builder::getIndexType(), mlir::Operation::getLoc(), getLocationToWriteFullVec(), mlir::Operation::getNumRegions(), mlir::Operation::getRegion(), mlir::Value::getType(), mlir::BlockAndValueMapping::map(), None, options, mlir::Operation::setAttr(), mlir::OpBuilder::setInsertionPoint(), mlir::OpBuilder::setInsertionPointToStart(), splitFullAndPartialTransferPrecondition(), mlir::succeeded(), mlir::success(), mlir::RewriterBase::updateRootInPlace(), and VectorTransfer.

Referenced by mlir::vector::VectorTransferFullPartialRewriter::matchAndRewrite().

◆ transferOpflowOpt()

void mlir::vector::transferOpflowOpt ( Operation rootOp)

Implements transfer op write to read forwarding and dead transfer write optimizations.

Definition at line 561 of file VectorTransferOpTransforms.cpp.

References mlir::Operation::walk().