MLIR  17.0.0git
Functions
VectorUtils.cpp File Reference
#include "mlir/Dialect/Vector/Utils/VectorUtils.h"
#include "mlir/Dialect/Affine/Analysis/LoopAnalysis.h"
#include "mlir/Dialect/Affine/IR/AffineOps.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Func/IR/FuncOps.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/IR/Builders.h"
#include "mlir/IR/IntegerSet.h"
#include "mlir/IR/Operation.h"
#include "mlir/IR/TypeUtilities.h"
#include "mlir/Support/LLVM.h"
#include "mlir/Support/MathExtras.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/SetVector.h"
+ Include dependency graph for VectorUtils.cpp:

Go to the source code of this file.

Functions

static AffineMap makePermutationMap (ArrayRef< Value > indices, const DenseMap< Operation *, unsigned > &enclosingLoopToVectorDim)
 Constructs a permutation map from memref indices to vector dimension. More...
 
template<typename T >
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...
 

Function Documentation

◆ getEnclosingforOps()

static SetVector<Operation *> getEnclosingforOps ( Block block)
static

Returns the enclosing AffineForOp, from closest to farthest.

Definition at line 121 of file VectorUtils.cpp.

◆ getParentsOfType()

template<typename T >
static SetVector<Operation *> getParentsOfType ( Block block)
static

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 107 of file VectorUtils.cpp.

References mlir::Block::getParentOp().

◆ makePermutationMap()

static AffineMap makePermutationMap ( ArrayRef< Value indices,
const DenseMap< Operation *, unsigned > &  enclosingLoopToVectorDim 
)
static

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:

  • keys representing "vectorized enclosing loops";
  • values representing the corresponding vector dimension. The algorithm traverses "vectorized enclosing loops" and extracts the at-most-one MemRef index that is invariant along said loop. This index is guaranteed to be at most one by construction: otherwise the MemRef is not vectorizable. If this invariant index is found, it is added to the permutation_map at the proper vector dimension. If no index is found to be invariant, 0 is added to the permutation_map and corresponds to a vector broadcast along that dimension.

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 68 of file VectorUtils.cpp.

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

Referenced by vectorizeAffineLoad(), and vectorizeAffineStore().