MLIR  19.0.0git
Macros | Functions
VectorTransferOpTransforms.cpp File Reference
#include "mlir/Dialect/Affine/IR/AffineOps.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Dialect/MemRef/Utils/MemRefUtils.h"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
#include "mlir/Dialect/Utils/IndexingUtils.h"
#include "mlir/Dialect/Vector/IR/VectorOps.h"
#include "mlir/Dialect/Vector/Transforms/LoweringPatterns.h"
#include "mlir/Dialect/Vector/Transforms/VectorTransforms.h"
#include "mlir/Dialect/Vector/Utils/VectorUtils.h"
#include "mlir/IR/Dominance.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Debug.h"

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "vector-transfer-opt"
 
#define DBGS()   (llvm::dbgs() << '[' << DEBUG_TYPE << "] ")
 

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. More...
 
static SmallVector< int64_t > getReducedShape (ArrayRef< OpFoldResult > mixedSizes)
 Converts OpFoldResults to int64_t shape without unit dims. More...
 
static MemRefType dropUnitDims (MemRefType inputType, ArrayRef< OpFoldResult > offsets, ArrayRef< OpFoldResult > sizes, ArrayRef< OpFoldResult > strides)
 Drops unit dimensions from the input MemRefType. More...
 
static Value rankReducingSubviewDroppingUnitDims (PatternRewriter &rewriter, mlir::Location loc, Value input)
 Creates a rank-reducing memref.subview op that drops unit dims from its input. More...
 
static int getReducedRank (ArrayRef< int64_t > shape)
 Returns the number of dims that aren't unit dims. More...
 
static VectorType trimNonScalableUnitDims (VectorType oldType)
 Trims non-scalable one dimensions from oldType and returns the result type. More...
 
static FailureOr< ValuecreateMaskDropNonScalableUnitDims (PatternRewriter &rewriter, Location loc, vector::CreateMaskOp op)
 
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. More...
 
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. More...
 

Macro Definition Documentation

◆ DBGS

#define DBGS ( )    (llvm::dbgs() << '[' << DEBUG_TYPE << "] ")

Definition at line 32 of file VectorTransferOpTransforms.cpp.

◆ DEBUG_TYPE

#define DEBUG_TYPE   "vector-transfer-opt"

Definition at line 30 of file VectorTransferOpTransforms.cpp.

Function Documentation

◆ collapseInnerDims()

static 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 493 of file VectorTransferOpTransforms.cpp.

References mlir::OpBuilder::create(), and mlir::Value::getType().

◆ createMaskDropNonScalableUnitDims()

static FailureOr<Value> createMaskDropNonScalableUnitDims ( PatternRewriter rewriter,
Location  loc,
vector::CreateMaskOp  op 
)
static

Definition at line 329 of file VectorTransferOpTransforms.cpp.

◆ dropUnitDims()

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

Drops unit dimensions from the input MemRefType.

Definition at line 278 of file VectorTransferOpTransforms.cpp.

References mlir::canonicalizeStridedLayout(), and getReducedShape().

Referenced by rankReducingSubviewDroppingUnitDims().

◆ findAncestorOpInRegion()

static 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.

◆ getCollapsedIndices()

static 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 510 of file VectorTransferOpTransforms.cpp.

References mlir::computeLinearIndex(), mlir::computeSuffixProduct(), mlir::OpBuilder::create(), mlir::getConstantIntValue(), mlir::isZeroIndex(), and mlir::affine::makeComposedFoldedAffineApply().

◆ getReducedRank()

static int getReducedRank ( ArrayRef< int64_t >  shape)
static

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

Definition at line 309 of file VectorTransferOpTransforms.cpp.

◆ getReducedShape()

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

Converts OpFoldResults to int64_t shape without unit dims.

Definition at line 261 of file VectorTransferOpTransforms.cpp.

Referenced by dropUnitDims().

◆ rankReducingSubviewDroppingUnitDims()

static 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 290 of file VectorTransferOpTransforms.cpp.

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

◆ trimNonScalableUnitDims()

static VectorType trimNonScalableUnitDims ( VectorType  oldType)
static

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

Definition at line 315 of file VectorTransferOpTransforms.cpp.

References mlir::detail::enumerate(), and mlir::get().