MLIR
20.0.0git
|
#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/Linalg/IR/Linalg.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
#include "mlir/IR/AffineExpr.h"
#include "mlir/IR/AffineExprVisitor.h"
#include "mlir/IR/AffineMap.h"
#include "mlir/IR/BuiltinTypeInterfaces.h"
#include "mlir/IR/MLIRContext.h"
#include "mlir/IR/TypeUtilities.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SetOperations.h"
#include "llvm/ADT/SmallBitVector.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <numeric>
#include <optional>
#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 | |
Include the generated interface declarations. | |
mlir::linalg | |
mlir::linalg::detail | |
Functions | |
static bool | isaElemwiseSingleUnaryOrBinaryOpInterface (linalg::GenericOp op, unsigned arity) |
static Value | getSourceSkipUnary (Value value) |
If the value is defined by a chain of unary side effect-free, go up the use-def chain until the first value that isn't defined by such an op. More... | |
template<typename AddOpTy , typename MulOpTy , typename... Args> | |
static bool | isPairTemplateImpl (Operation *add, Operation *mul) |
Returns true if the two operations are of the kinds specified by a pair of consecutive template arguments. More... | |
template<typename... Args> | |
static bool | isContractionBody (Block &block) |
Returns true if the block is a body of a contraction with the kinds of operations given pairwise by template arguments. More... | |
static llvm::SmallDenseSet< int64_t > | findPermutationsIndexingOperand (AffineMap indexingMap, ArrayRef< utils::IteratorType > iterators, utils::IteratorType iter) |
Given an indexingMap and its corresponding iterators , returns the positions of the iterators of type iter that are indexed by the indexingMap as a permutation. More... | |
static FailureOr< SmallVector< utils::IteratorType > > | inferIteratorsFromOutMap (AffineMap map) |
Infer the iterator types from the init affine map. More... | |
static FailureOr< ContractionDimensions > | inferContractionDimsImpl (ArrayRef< AffineMap > indexingMaps, ArrayRef< utils::IteratorType > iterators) |
Find 2 parallel (m and n) and 1 reduction (k) dimension candidates that form a matmul subcomputation within linalgOp . More... | |
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< int64_t > | getPreservedDims (AffineMap map) |
static SmallVector< int64_t, 2 > | getConstantsFromExprList (const SmallVector< AffineExpr, 2 > &exprs) |
static FailureOr< ConvolutionDimensions > | inferConvolutionDimsImpl (LinalgOp linalgOp, ConvAccessExprWalker &inputExprWalker, bool allowEmptyConvolvedDims) |
Classifies dimensions in the linalgOp used by a convolution subcomputation, as captured by inputExprWalker . More... | |
static MatchFillResult | isFillInterfaceImpl (Operation *op) |
static std::pair< int64_t, int64_t > | getResultsPositionInLoopsToShapeMap (LinalgOp &op) |
|
strong |
Enumerator | |
---|---|
Success | |
NotLinalgOp | |
WrongNumOperands | |
NotScalarInput |
Definition at line 1025 of file LinalgInterfaces.cpp.
|
static |
Given an indexingMap
and its corresponding iterators
, returns the positions of the iterators of type iter
that are indexed by the indexingMap
as a permutation.
This is useful to infer various subcomputations on a LinalgOp
. This is performed by looking up each result in the indexingMap
and determining whether:
Definition at line 357 of file LinalgInterfaces.cpp.
References mlir::AffineMap::getNumDims(), and mlir::AffineMap::getResults().
Referenced by inferContractionDimsImpl(), and inferConvolutionDimsImpl().
|
static |
Of the given two expressions returns one that is of type T (lhs
gets preference over rhs
)
Definition at line 566 of file LinalgInterfaces.cpp.
|
static |
Definition at line 688 of file LinalgInterfaces.cpp.
Referenced by inferConvolutionDimsImpl().
|
static |
Definition at line 678 of file LinalgInterfaces.cpp.
References mlir::AffineMap::getResults(), and mlir::AffineMap::isProjectedPermutation().
Referenced by mlir::linalg::detail::isConvolutionInterfaceImpl().
|
static |
Definition at line 1134 of file LinalgInterfaces.cpp.
If the value is defined by a chain of unary side effect-free, go up the use-def chain until the first value that isn't defined by such an op.
Definition at line 251 of file LinalgInterfaces.cpp.
References mlir::Value::getDefiningOp(), mlir::Operation::getNumOperands(), and mlir::Operation::getOperand().
Referenced by mlir::linalg::detail::isContractionBody().
|
static |
Find 2 parallel (m and n) and 1 reduction (k) dimension candidates that form a matmul subcomputation within linalgOp
.
These dimensions are such that:
linalgOp
with some orthogonal heuristic. Definition at line 406 of file LinalgInterfaces.cpp.
References findPermutationsIndexingOperand().
Referenced by mlir::linalg::inferContractionDims().
|
static |
Classifies dimensions in the linalgOp
used by a convolution subcomputation, as captured by inputExprWalker
.
If allowEmptyConvolvedDims
is not set this this will fail if there is not at least convolved dimension pair (output image + filter loop). Convolution dimensions are specified in sorted order, and strides match the order of the filter loop dimensions, while the dilations match the order of the output image dimensions.
Definition at line 706 of file LinalgInterfaces.cpp.
References findPermutationsIndexingOperand(), and getConstantsFromExprList().
Referenced by mlir::linalg::inferConvolutionDims(), and mlir::linalg::detail::isConvolutionInterfaceImpl().
|
static |
Infer the iterator types from the init affine map.
This looks at which dims are present in the map results, and returns an iterator types array with parallel types for dims that are present, and reduction types for dims that are not present.
Definition at line 384 of file LinalgInterfaces.cpp.
References mlir::AffineMap::getNumDims(), mlir::AffineMap::getResults(), and mlir::AffineMap::isProjectedPermutation().
Referenced by mlir::linalg::inferContractionDims().
|
static |
Definition at line 184 of file LinalgInterfaces.cpp.
References mlir::Block::back(), mlir::Block::front(), mlir::Operation::getNumOperands(), mlir::Operation::getNumResults(), and mlir::Block::getOperations().
|
static |
Returns true if the block is a body of a contraction with the kinds of operations given pairwise by template arguments.
Definition at line 345 of file LinalgInterfaces.cpp.
References mlir::linalg::detail::isContractionBody().
|
static |
Definition at line 1032 of file LinalgInterfaces.cpp.
References NotLinalgOp, NotScalarInput, Success, and WrongNumOperands.
Referenced by mlir::linalg::detail::verifyFillInterface().
|
static |
Returns true if the two operations are of the kinds specified by a pair of consecutive template arguments.
Definition at line 330 of file LinalgInterfaces.cpp.