MLIR 24.0.0git
VectorUnroll.cpp File Reference
#include "mlir/Dialect/Affine/IR/AffineOps.h"
#include "mlir/Dialect/Utils/IndexingUtils.h"
#include "mlir/Dialect/Vector/Transforms/LoweringPatterns.h"
#include "mlir/Dialect/Vector/Transforms/VectorTransforms.h"
#include "mlir/Dialect/Vector/Utils/VectorUtils.h"
#include "mlir/Interfaces/VectorInterfaces.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/DebugLog.h"
#include "llvm/Support/InterleavedRange.h"
#include <optional>

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "vector-unroll"

Functions

static SmallVector< Value > sliceLoadStoreIndices (PatternRewriter &rewriter, Location loc, OperandRange originalIndices, ArrayRef< int64_t > offsets)
static Operation * cloneOpWithOperandsAndTypes (OpBuilder &builder, Location loc, Operation *op, ArrayRef< Value > operands, ArrayRef< Type > resultTypes)
static std::optional< SmallVector< int64_t > > getTargetShape (const vector::UnrollVectorOptions &options, VectorUnrollOpInterface &iface, bool allowMasked=false)
 Return the target shape for unrolling for the given op, provided through its VectorUnrollOpInterface object, iface.
template<typename TransferOpTy>
static LogicalResult checkSupportedMaskedTransferUnrolling (TransferOpTy xferOp, PatternRewriter &rewriter)
 Fail if xferOp, masked by an enclosing vector.mask, is masked in a way that the transfer unrolling patterns do not support yet.
static bool hasUnsupportedScalableDims (VectorType vectorType, ArrayRef< int64_t > targetShape)
 Return true if a non-trailing vector dim is scalable, or if the target shape would split the scalable trailing vector dim.
static Operation * maskTile (PatternRewriter &rewriter, Location loc, Operation *tiledXferOp, vector::MaskingOpInterface maskingOp, ArrayRef< int64_t > offsets, ArrayRef< int64_t > sizes, ArrayRef< int64_t > strides)
 Wrap tiledXferOp, the new transfer for one tile, in a vector.mask with the tile of maskingOp's mask (and passthru, if any) at offsets with shape sizes.

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "vector-unroll"

Definition at line 25 of file VectorUnroll.cpp.

Function Documentation

◆ checkSupportedMaskedTransferUnrolling()

template<typename TransferOpTy>
LogicalResult checkSupportedMaskedTransferUnrolling ( TransferOpTy xferOp,
PatternRewriter & rewriter )
static

Fail if xferOp, masked by an enclosing vector.mask, is masked in a way that the transfer unrolling patterns do not support yet.

Definition at line 153 of file VectorUnroll.cpp.

References mlir::RewriterBase::notifyMatchFailure(), and success().

◆ cloneOpWithOperandsAndTypes()

◆ getTargetShape()

std::optional< SmallVector< int64_t > > getTargetShape ( const vector::UnrollVectorOptions & options,
VectorUnrollOpInterface & iface,
bool allowMasked = false )
static

Return the target shape for unrolling for the given op, provided through its VectorUnrollOpInterface object, iface.

Return std::nullopt if the op shouldn't be or cannot be unrolled. Ops masked by an enclosing vector.mask are rejected unless allowMasked is set, which only patterns that slice the mask for each unrolled op may do.

ATM, target shape can be specified two-fold:

  1. Via VectorUnrollOpInterface (see getDefaultUnrollTargetShape).
  2. Via UnrollVectorOptions (see nativeShape).

Input from a "user" always takes precedence, i.e. 1. is used iff 2. (used for "user" input) is not available.

Definition at line 102 of file VectorUnroll.cpp.

References mlir::computeShapeRatio(), mlir::Operation::getName(), mlir::OperationName::getStringRef(), and options.

◆ hasUnsupportedScalableDims()

bool hasUnsupportedScalableDims ( VectorType vectorType,
ArrayRef< int64_t > targetShape )
static

Return true if a non-trailing vector dim is scalable, or if the target shape would split the scalable trailing vector dim.

Scalable dims must remain whole because tile offsets are static. TODO: Splitting the trailing scalable dim could be supported with vector.scalable.extract and vector.scalable.insert.

Definition at line 176 of file VectorUnroll.cpp.

◆ maskTile()

Operation * maskTile ( PatternRewriter & rewriter,
Location loc,
Operation * tiledXferOp,
vector::MaskingOpInterface maskingOp,
ArrayRef< int64_t > offsets,
ArrayRef< int64_t > sizes,
ArrayRef< int64_t > strides )
static

Wrap tiledXferOp, the new transfer for one tile, in a vector.mask with the tile of maskingOp's mask (and passthru, if any) at offsets with shape sizes.

maskingOp is the vector.mask around the original transfer; tiledXferOp is created outside of it. Return tiledXferOp itself if maskingOp is null.

Definition at line 192 of file VectorUnroll.cpp.

References mlir::OpBuilder::createOrFold(), and mlir::vector::maskOperation().

◆ sliceLoadStoreIndices()

SmallVector< Value > sliceLoadStoreIndices ( PatternRewriter & rewriter,
Location loc,
OperandRange originalIndices,
ArrayRef< int64_t > offsets )
static

Definition at line 58 of file VectorUnroll.cpp.

References mlir::arith::ConstantIndexOp::create(), and indices.