MLIR  17.0.0git
Classes | Namespaces | Enumerations | Functions
LinalgInterfaces.cpp File Reference
#include "mlir/Dialect/Linalg/IR/LinalgInterfaces.h"
#include "mlir/Dialect/Affine/IR/AffineOps.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Arith/Utils/Utils.h"
#include "mlir/Dialect/Complex/IR/Complex.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
#include "mlir/IR/AffineExprVisitor.h"
#include "mlir/IR/AffineMap.h"
#include "mlir/IR/TypeUtilities.h"
#include "llvm/ADT/SmallBitVector.h"
#include "mlir/Dialect/Linalg/IR/LinalgInterfaces.cpp.inc"

Go to the source code of this file.

Classes

struct  HasAffineDimExprVisitor
 Visitor to check if any of the given set of positions from AffineDimExprs are used within an AffineExpr. More...
 

Namespaces

 mlir
 This header declares functions that assist transformations in the MemRef dialect.
 
 mlir::linalg
 
 mlir::linalg::detail
 

Enumerations

enum class  MatchContractionResult {
  Success = 0 , NotLinalgOp , WrongNumOperands , NoReduction ,
  NotProjectedPermutations , NotAddMul
}
 
enum class  mlir::linalg::detail::MatchConvolutionResult {
  mlir::linalg::detail::Success = 0 , mlir::linalg::detail::NotLinalgOp , mlir::linalg::detail::WrongNumOperands , mlir::linalg::detail::WrongInputIndexingMap ,
  mlir::linalg::detail::NotProjectedPermutations , mlir::linalg::detail::NonConvolutionLoop , mlir::linalg::detail::OutputDimsNotParallel , mlir::linalg::detail::NonOutputDimNotReduction
}
 
enum class  MatchFillResult { Success = 0 , NotLinalgOp , WrongNumOperands , NotScalarInput }
 

Functions

static bool isChainOfUnaryOpsFrom (Value v, Value from)
 Return true if the use-def chain from v to from consists of 0 or more unary single-operand operations. More...
 
template<typename OpType >
static OpType getSingleOpOfType (Block &block)
 Return the unique instance of OpType in block if it is indeed unique. More...
 
template<typename AddOpType , typename MulOpType >
static bool isAddMul (Block &block)
 Detect whether res is any permutation of u5(u1(c) + u2(u3(a) * u4(b))) on the field (AddOpType, MulOpType), where u1, u2, u3, u4 and u5 represent unary operations that may change the type. More...
 
static MatchContractionResult isContractionInterfaceImpl (Operation *op)
 
template<typename T >
static T getAffineExprOfType (AffineExpr lhs, AffineExpr rhs)
 Of the given two expressions returns one that is of type T (lhs gets preference over rhs) More...
 
static llvm::SmallDenseSet< unsigned > getPreservedDims (AffineMap map)
 
static MatchFillResult isFillInterfaceImpl (Operation *op)
 
static Value createOrFoldDimOp (OpBuilder &b, Location loc, Value source, int64_t dim)
 Helper function that creates a memref::DimOp or tensor::DimOp depending on the type of source. More...
 
static OpFoldResult createFoldedDimOp (OpBuilder &b, Location loc, Value source, int64_t dim)
 
static std::pair< int64_t, int64_t > getResultsPositionInLoopsToShapeMap (LinalgOp &op)
 

Enumeration Type Documentation

◆ MatchContractionResult

Enumerator
Success 
NotLinalgOp 
WrongNumOperands 
NoReduction 
NotProjectedPermutations 
NotAddMul 

Definition at line 115 of file LinalgInterfaces.cpp.

◆ MatchFillResult

enum MatchFillResult
strong
Enumerator
Success 
NotLinalgOp 
WrongNumOperands 
NotScalarInput 

Definition at line 468 of file LinalgInterfaces.cpp.

Function Documentation

◆ createFoldedDimOp()

static OpFoldResult createFoldedDimOp ( OpBuilder b,
Location  loc,
Value  source,
int64_t  dim 
)
static

◆ createOrFoldDimOp()

static Value createOrFoldDimOp ( OpBuilder b,
Location  loc,
Value  source,
int64_t  dim 
)
static

Helper function that creates a memref::DimOp or tensor::DimOp depending on the type of source.

Definition at line 507 of file LinalgInterfaces.cpp.

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

◆ getAffineExprOfType()

template<typename T >
static T getAffineExprOfType ( AffineExpr  lhs,
AffineExpr  rhs 
)
static

Of the given two expressions returns one that is of type T (lhs gets preference over rhs)

Definition at line 188 of file LinalgInterfaces.cpp.

References mlir::AffineExpr::cast(), and mlir::AffineExpr::isa().

◆ getPreservedDims()

static llvm::SmallDenseSet<unsigned> getPreservedDims ( AffineMap  map)
static

◆ getResultsPositionInLoopsToShapeMap()

static std::pair<int64_t, int64_t> getResultsPositionInLoopsToShapeMap ( LinalgOp &  op)
static

Definition at line 595 of file LinalgInterfaces.cpp.

◆ getSingleOpOfType()

template<typename OpType >
static OpType getSingleOpOfType ( Block block)
static

Return the unique instance of OpType in block if it is indeed unique.

Return null if none or more than 1 instances exist.

Definition at line 69 of file LinalgInterfaces.cpp.

References mlir::Block::walk().

◆ isAddMul()

template<typename AddOpType , typename MulOpType >
static bool isAddMul ( Block block)
static

Detect whether res is any permutation of u5(u1(c) + u2(u3(a) * u4(b))) on the field (AddOpType, MulOpType), where u1, u2, u3, u4 and u5 represent unary operations that may change the type.

Definition at line 86 of file LinalgInterfaces.cpp.

References mlir::Block::getArgument(), mlir::Block::getNumArguments(), mlir::Operation::getNumOperands(), mlir::Operation::getOperand(), mlir::Block::getTerminator(), isChainOfUnaryOpsFrom(), and mlir::success().

◆ isChainOfUnaryOpsFrom()

static bool isChainOfUnaryOpsFrom ( Value  v,
Value  from 
)
static

Return true if the use-def chain from v to from consists of 0 or more unary single-operand operations.

Definition at line 55 of file LinalgInterfaces.cpp.

Referenced by isAddMul().

◆ isContractionInterfaceImpl()

static MatchContractionResult isContractionInterfaceImpl ( Operation op)
static

Definition at line 123 of file LinalgInterfaces.cpp.

◆ isFillInterfaceImpl()

static MatchFillResult isFillInterfaceImpl ( Operation op)
static

Definition at line 475 of file LinalgInterfaces.cpp.