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/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 LogicalResult checkAndCollapseInnerZeroIndices (ValueRange indices, int64_t firstDimToCollapse, SmallVector< Value > &outIndices)
 Checks that the indices corresponding to dimensions starting at firstDimToCollapse are constant 0, and writes to outIndices the truncated indices where firstDimToCollapse is now the innermost dim. More...
 

Macro Definition Documentation

◆ DBGS

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

Definition at line 31 of file VectorTransferOpTransforms.cpp.

◆ DEBUG_TYPE

#define DEBUG_TYPE   "vector-transfer-opt"

Definition at line 29 of file VectorTransferOpTransforms.cpp.

Function Documentation

◆ checkAndCollapseInnerZeroIndices()

static LogicalResult checkAndCollapseInnerZeroIndices ( ValueRange  indices,
int64_t  firstDimToCollapse,
SmallVector< Value > &  outIndices 
)
static

Checks that the indices corresponding to dimensions starting at firstDimToCollapse are constant 0, and writes to outIndices the truncated indices where firstDimToCollapse is now the innermost dim.

TODO: Extract the logic that writes to outIndices so that this method simply checks one pre-condition.

Definition at line 517 of file VectorTransferOpTransforms.cpp.

References mlir::failure(), mlir::getConstantIntValue(), and mlir::success().

◆ 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 496 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 332 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 281 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 37 of file VectorTransferOpTransforms.cpp.

◆ getReducedRank()

static int getReducedRank ( ArrayRef< int64_t >  shape)
static

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

Definition at line 312 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 264 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 293 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 318 of file VectorTransferOpTransforms.cpp.

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