MLIR: lib/Dialect/Vector/Utils/VectorUtils.cpp File Reference (original) (raw)

Go to the source code of this file.

Macros
#define DEBUG_TYPE "vector-utils"
#define DBGS() (llvm::dbgs() << '[' << DEBUG_TYPE << "] ")
#define LDBG(X) LLVM_DEBUG(DBGS() << X << "\n")
Functions
static bool areDimsTransposedIn2DSlice (int64_t dim0, int64_t dim1, ArrayRef< int64_t > transp)
Given the n-D transpose pattern 'transp', return true if 'dim0' and 'dim1' should be transposed with each other within the context of their 2D transposition slice. More...
static AffineMap makePermutationMap (ArrayRef< Value > indices, const DenseMap< Operation *, unsigned > &enclosingLoopToVectorDim)
Constructs a permutation map from memref indices to vector dimension. More...
template
static SetVector< Operation * > getParentsOfType (Block *block)
Implementation detail that walks up the parents and records the ones with the specified type. More...
static SetVector< Operation * > getEnclosingforOps (Block *block)
Returns the enclosing AffineForOp, from closest to farthest. More...

DBGS

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

DEBUG_TYPE

#define DEBUG_TYPE "vector-utils"

LDBG

| #define LDBG | ( | | X | ) | LLVM_DEBUG(DBGS() << X << "\n") | | ------------ | - | | - | - | ---------------------------------------------------------------------------------------------- |

areDimsTransposedIn2DSlice()

static bool areDimsTransposedIn2DSlice ( int64_t dim0, int64_t dim1, ArrayRef< int64_t > transp ) static

Given the n-D transpose pattern 'transp', return true if 'dim0' and 'dim1' should be transposed with each other within the context of their 2D transposition slice.

Example 1: dim0 = 0, dim1 = 2, transp = [2, 1, 0] Return true: dim0 and dim1 are transposed within the context of their 2D transposition slice ([1, 0]).

Example 2: dim0 = 0, dim1 = 1, transp = [2, 1, 0] Return true: dim0 and dim1 are transposed within the context of their 2D transposition slice ([1, 0]). Paradoxically, note how dim1 (1) is not transposed within the full context of the transposition.

Example 3: dim0 = 0, dim1 = 1, transp = [2, 0, 1] Return false: dim0 and dim1 are not transposed within the context of their 2D transposition slice ([0, 1]). Paradoxically, note how dim0 (0) and dim1 (1) are transposed within the full context of the of the transposition.

Definition at line 68 of file VectorUtils.cpp.

Referenced by mlir::vector::isTranspose2DSlice().

getEnclosingforOps()

Returns the enclosing AffineForOp, from closest to farthest.

Definition at line 179 of file VectorUtils.cpp.

getParentsOfType()

Implementation detail that walks up the parents and records the ones with the specified type.

TODO: could also be implemented as a collect parents followed by a filter and made available outside this file.

Definition at line 165 of file VectorUtils.cpp.

References mlir::Block::getParentOp().

makePermutationMap()

Constructs a permutation map from memref indices to vector dimension.

The implementation uses the knowledge of the mapping of enclosing loop to vector dimension. enclosingLoopToVectorDim carries this information as a map with:

Returns an empty AffineMap if enclosingLoopToVectorDim is empty, signalling that no permutation map can be constructed given enclosingLoopToVectorDim.

Examples can be found in the documentation of makePermutationMap, in the header file.

Definition at line 126 of file VectorUtils.cpp.

References mlir::AffineMap::get(), mlir::getAffineConstantExpr(), mlir::getAffineDimExpr(), and mlir::affine::getInvariantAccesses().