MLIR 23.0.0git
VectorTransferOpTransforms.cpp File Reference

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "vector-transfer-opt"

Functions

static OperationfindAncestorOpInRegion (Region *region, Operation *op)
 Return the ancestor op in the region or nullptr if the region is not an ancestor of the op.
static SmallVector< int64_tgetReducedShape (ArrayRef< OpFoldResult > mixedSizes)
 Converts OpFoldResults to int64_t shape without unit dims.
static MemRefType dropUnitDims (MemRefType inputType, ArrayRef< OpFoldResult > offsets, ArrayRef< OpFoldResult > sizes, ArrayRef< OpFoldResult > strides)
 Drops unit dimensions from the input MemRefType.
static Value rankReducingSubviewDroppingUnitDims (PatternRewriter &rewriter, mlir::Location loc, Value input)
 Creates a rank-reducing memref.subview op that drops unit dims from its input.
static int getReducedRank (ArrayRef< int64_t > shape)
 Returns the number of dims that aren't unit dims.
static VectorType trimNonScalableUnitDims (VectorType oldType)
 Trims non-scalable one dimensions from oldType and returns the result type.
static bool isUnitDimMask (Value maskDimSize)
static bool isUnitDimMask (int64_t maskDimSize)
template<typename MaskOp>
static FailureOr< ValuemaskDropNonScalableUnitDims (PatternRewriter &rewriter, Location loc, MaskOp op)
 Rewrites a mask op to drop non-scalable unit dimensions.
static Value collapseInnerDims (PatternRewriter &rewriter, mlir::Location loc, Value input, int64_t firstDimToCollapse)
 Creates a memref.collapse_shape collapsing all inner dimensions of the input starting at firstDimToCollapse.
static SmallVector< ValuegetCollapsedIndices (RewriterBase &rewriter, Location loc, ArrayRef< int64_t > shape, ValueRange indices, int64_t firstDimToCollapse)
 Returns the new indices that collapses the inner dimensions starting from the firstDimToCollapse dimension.

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "vector-transfer-opt"

Definition at line 32 of file VectorTransferOpTransforms.cpp.

Function Documentation

◆ collapseInnerDims()

Value collapseInnerDims ( PatternRewriter & rewriter,
mlir::Location loc,
Value input,
int64_t firstDimToCollapse )
static

Creates a memref.collapse_shape collapsing all inner dimensions of the input starting at firstDimToCollapse.

Definition at line 704 of file VectorTransferOpTransforms.cpp.

References mlir::Value::getType().

◆ dropUnitDims()

MemRefType dropUnitDims ( MemRefType inputType,
ArrayRef< OpFoldResult > offsets,
ArrayRef< OpFoldResult > sizes,
ArrayRef< OpFoldResult > strides )
static

Drops unit dimensions from the input MemRefType.

Definition at line 384 of file VectorTransferOpTransforms.cpp.

References getReducedShape().

Referenced by rankReducingSubviewDroppingUnitDims().

◆ findAncestorOpInRegion()

Operation * findAncestorOpInRegion ( Region * region,
Operation * op )
static

Return the ancestor op in the region or nullptr if the region is not an ancestor of the op.

Definition at line 38 of file VectorTransferOpTransforms.cpp.

References mlir::Operation::getParentOp(), and mlir::Operation::getParentRegion().

Referenced by mlir::applyOpPatternsGreedily().

◆ getCollapsedIndices()

SmallVector< Value > getCollapsedIndices ( RewriterBase & rewriter,
Location loc,
ArrayRef< int64_t > shape,
ValueRange indices,
int64_t firstDimToCollapse )
static

Returns the new indices that collapses the inner dimensions starting from the firstDimToCollapse dimension.

Definition at line 721 of file VectorTransferOpTransforms.cpp.

References mlir::computeLinearIndex(), mlir::computeSuffixProduct(), mlir::arith::ConstantIndexOp::create(), mlir::getConstantIntValue(), indices, mlir::isZeroInteger(), and mlir::affine::makeComposedFoldedAffineApply().

◆ getReducedRank()

int getReducedRank ( ArrayRef< int64_t > shape)
static

Returns the number of dims that aren't unit dims.

Definition at line 415 of file VectorTransferOpTransforms.cpp.

◆ getReducedShape()

SmallVector< int64_t > getReducedShape ( ArrayRef< OpFoldResult > mixedSizes)
static

Converts OpFoldResults to int64_t shape without unit dims.

Definition at line 367 of file VectorTransferOpTransforms.cpp.

Referenced by dropUnitDims().

◆ isUnitDimMask() [1/2]

bool isUnitDimMask ( int64_t maskDimSize)
static

Definition at line 436 of file VectorTransferOpTransforms.cpp.

◆ isUnitDimMask() [2/2]

bool isUnitDimMask ( Value maskDimSize)
static

Definition at line 433 of file VectorTransferOpTransforms.cpp.

References mlir::m_One(), and mlir::matchPattern().

Referenced by maskDropNonScalableUnitDims().

◆ maskDropNonScalableUnitDims()

template<typename MaskOp>
FailureOr< Value > maskDropNonScalableUnitDims ( PatternRewriter & rewriter,
Location loc,
MaskOp op )
static

Rewrites a mask op to drop non-scalable unit dimensions.

Supports vector.create_mask and vector.constant_mask.

Definition at line 441 of file VectorTransferOpTransforms.cpp.

References isUnitDimMask(), and trimNonScalableUnitDims().

◆ rankReducingSubviewDroppingUnitDims()

Value rankReducingSubviewDroppingUnitDims ( PatternRewriter & rewriter,
mlir::Location loc,
Value input )
static

Creates a rank-reducing memref.subview op that drops unit dims from its input.

Or just returns the input if it was already without unit dims.

Definition at line 396 of file VectorTransferOpTransforms.cpp.

References dropUnitDims(), mlir::Builder::getIndexAttr(), mlir::memref::getMixedSizes(), and mlir::Value::getType().

◆ trimNonScalableUnitDims()

VectorType trimNonScalableUnitDims ( VectorType oldType)
static

Trims non-scalable one dimensions from oldType and returns the result type.

Definition at line 421 of file VectorTransferOpTransforms.cpp.

Referenced by maskDropNonScalableUnitDims().