MLIR
18.0.0git
|
#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/Tensor/IR/Tensor.h"
#include "mlir/Dialect/Utils/IndexingUtils.h"
#include "mlir/Dialect/Utils/ReshapeOpsUtils.h"
#include "mlir/Dialect/Utils/StaticValueUtils.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinAttributeInterfaces.h"
#include "mlir/IR/BuiltinTypeInterfaces.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/IRMapping.h"
#include "mlir/IR/Matchers.h"
#include "mlir/IR/OpDefinition.h"
#include "mlir/IR/TypeUtilities.h"
#include "mlir/Interfaces/DestinationStyleOpInterface.h"
#include "mlir/Interfaces/LoopLikeInterface.h"
#include "mlir/Support/MathExtras.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallBitVector.h"
#include "llvm/ADT/StringRef.h"
#include <algorithm>
#include <optional>
#include "mlir/Dialect/Tensor/IR/TensorOps.cpp.inc"
Go to the source code of this file.
Classes | |
struct | SliceReturnTypeCanonicalizer |
Return the canonical type of the result of an extract_slice op. More... | |
struct | SliceCanonicalizer |
A canonicalizer wrapper to replace ExtractSliceOps. More... | |
struct | FoldTensorCastProducerOp |
Folds a tensor.cast op into a consuming DestinationStyleOpInterface op if the tensor.cast has source that is more static than the consuming op. More... | |
Macros | |
#define | GET_OP_CLASSES |
Functions | |
static llvm::SmallBitVector | getDroppedDims (ArrayRef< int64_t > reducedShape, ArrayRef< OpFoldResult > mixedSizes) |
Compute the dropped dimensions of a rank-reducing tensor.extract_slice op or rank-extending tensor.insert_slice op. More... | |
static TensorType | joinShapes (TensorType one, TensorType two) |
Compute a TensorType that has the joined shape knowledge of the two given TensorTypes. More... | |
static OpFoldResult | reshapeConstantSource (DenseElementsAttr source, TensorType result) |
Try to remove a tensor operation if it would only reshape a constant. More... | |
static LogicalResult | verifyGatherOrScatterDims (Operation *op, ArrayRef< int64_t > dims, int64_t rank, StringRef gatherOrScatter, StringRef sourceOrDest) |
static void | operandsAndShape (TensorType resultType, Operation::operand_range dynamicExtents, SmallVectorImpl< Value > &newOperands, SmallVectorImpl< int64_t > &newShape) |
Extract operands and shape from a tensor with dynamic extents. More... | |
static int64_t | getNumElements (ShapedType type) |
template<typename TensorReshapeOp , bool isExpansion = std::is_same< TensorReshapeOp, ExpandShapeOp>::value> | |
static LogicalResult | verifyTensorReshapeOp (TensorReshapeOp op, RankedTensorType expandedType, RankedTensorType collapsedType) |
static LogicalResult | produceSliceErrorMsg (SliceVerificationResult result, Operation *op, RankedTensorType expectedType) |
static LogicalResult | foldIdentityOffsetSizeAndStrideOpInterface (OffsetSizeAndStrideOpInterface op, ShapedType shapedType) |
static Value | foldExtractAfterInsertSlice (ExtractSliceOp extractOp) |
If we have an ExtractSliceOp consuming an InsertSliceOp with the same slice, we can return the InsertSliceOp's source directly. More... | |
static SliceVerificationResult | verifyInsertSliceOp (RankedTensorType srcType, RankedTensorType dstType, ArrayRef< int64_t > staticOffsets, ArrayRef< int64_t > staticSizes, ArrayRef< int64_t > staticStrides, RankedTensorType *expectedType=nullptr) |
Rank-reducing type verification for both InsertSliceOp and ParallelInsertSliceOp. More... | |
static LogicalResult | foldInsertAfterInsertSlice (InsertSliceOp insertOp) |
If we have two consecutive InsertSliceOp writing to the same slice, we can mutate the second InsertSliceOp's destination to the first one's. More... | |
static Value | foldInsertAfterExtractSlice (InsertSliceOp insertOp) |
Folds round-trip extract/insert slice op pairs. More... | |
void | printInferType (OpAsmPrinter &printer, Operation *op, Value optOperand, Type typeToInfer, Type typeToInferFrom) |
ParseResult | parseInferType (OpAsmParser &parser, std::optional< OpAsmParser::UnresolvedOperand > optOperand, Type &typeToInfer, Type typeToInferFrom) |
template<typename OpTy > | |
static LogicalResult | reifyResultShapesImpl (OpTy op, OpBuilder &builder, ReifiedRankedShapedTypeDims &reifiedReturnShapes) |
template<typename OpTy > | |
static DenseMap< int64_t, OpFoldResult > | getDimAndTileMappingImpl (OpTy op) |
template<typename OpTy > | |
static SmallVector< OpFoldResult > | getMixedTilesImpl (OpTy op) |
template<typename OpTy > | |
static SmallVector< int64_t > | getStaticTilesImpl (OpTy op) |
static bool | isInvalidPackingPosSpecification (ArrayRef< int64_t > dimsPos, size_t rank) |
Returns true if dimsPos is invalid. More... | |
static bool | areAllInBound (ArrayRef< int64_t > sourceShape, ArrayRef< int64_t > limitShape) |
Returns true if the dimension of sourceShape is smaller than the dimension of the limitShape . More... | |
template<typename OpTy > | |
static LogicalResult | commonVerifierPackAndUnPackOp (OpTy packOrUnPack) |
template<typename OpTy > | |
static PackOrUnPackTransposeResult | commonPermutationOfPackAndUnPackOp (OpTy packOrUnPackOp, ArrayRef< int64_t > innerPermutation, ArrayRef< int64_t > outerPermutation) |
static SmallVector< int64_t > | asShapeWithAnyValueAsDynamic (ArrayRef< OpFoldResult > ofrs) |
Converts OpFoldResults to int64_t shape entries, unconditionally mapping all Value's to kDynamic, even if they are arith.constant values. More... | |
static SmallVector< int64_t > | getPackOpResultTypeShape (ArrayRef< int64_t > sourceShape, ArrayRef< int64_t > innerTileSizes, ArrayRef< int64_t > innerDimsPos, ArrayRef< int64_t > outerDimsPerm) |
Helper for PackOp::{getResultShape,inferPackedType}. More... | |
template<typename OpTy > | |
bool | areTilesAndTiledDimsAllConstant (OpTy op) |
Returns true if the tiles and the tiled dims are constant. More... | |
static bool | hasSameInnerOuterAttribute (PackOp packOp, UnPackOp unPackOp) |
static bool | haveSameTiles (PackOp packOp, UnPackOp unPackOp) |
static bool | paddingIsNotNeeded (PackOp op) |
Returns true if the pack op does not need a padding value. More... | |
template<typename PackOrUnpackOp > | |
static bool | isLikePadUnPad (PackOrUnpackOp packOp, RankedTensorType packedTensorType) |
#define GET_OP_CLASSES |
Definition at line 4301 of file TensorOps.cpp.
|
static |
Returns true if the dimension of sourceShape
is smaller than the dimension of the limitShape
.
Definition at line 3564 of file TensorOps.cpp.
bool areTilesAndTiledDimsAllConstant | ( | OpTy | op | ) |
Returns true if the tiles and the tiled dims are constant.
Definition at line 3939 of file TensorOps.cpp.
|
static |
Converts OpFoldResults to int64_t shape entries, unconditionally mapping all Value's to kDynamic, even if they are arith.constant values.
Definition at line 3805 of file TensorOps.cpp.
References mlir::getConstantIntValue().
|
static |
Definition at line 3683 of file TensorOps.cpp.
References mlir::applyPermutationToVector(), and mlir::isPermutationVector().
|
static |
Definition at line 3579 of file TensorOps.cpp.
|
static |
If we have an ExtractSliceOp consuming an InsertSliceOp with the same slice, we can return the InsertSliceOp's source directly.
Definition at line 2358 of file TensorOps.cpp.
References mlir::Value::getDefiningOp().
|
static |
Definition at line 2336 of file TensorOps.cpp.
|
static |
Folds round-trip extract/insert slice op pairs.
Example:
can be folded into val.
Definition at line 2504 of file TensorOps.cpp.
References mlir::Value::getDefiningOp().
|
static |
If we have two consecutive InsertSliceOp writing to the same slice, we can mutate the second InsertSliceOp's destination to the first one's.
Example:
folds into:
This pattern works with both InsertSliceOp and ParallelInsertSliceOp.
Definition at line 2484 of file TensorOps.cpp.
References mlir::failure(), and mlir::success().
|
static |
Definition at line 3503 of file TensorOps.cpp.
|
static |
Compute the dropped dimensions of a rank-reducing tensor.extract_slice op or rank-extending tensor.insert_slice op.
Definition at line 131 of file TensorOps.cpp.
References mlir::detail::enumerate().
|
static |
Definition at line 3518 of file TensorOps.cpp.
|
static |
Definition at line 1539 of file TensorOps.cpp.
Referenced by mlir::LLVM::detail::extractNDVectorTypeInfo(), hasAtMostSingleNonScalar(), mlir::affine::AffineDmaStartOp::print(), and mlir::affine::AffineDmaWaitOp::print().
|
static |
Helper for PackOp::{getResultShape,inferPackedType}.
Returns the shape of the packed type. Having a shared helper helps implement these two methods in a way that ensures that they agree on which dimensions are dynamic.
Definition at line 3820 of file TensorOps.cpp.
References mlir::applyPermutationToVector(), mlir::ceilDiv(), and mlir::detail::enumerate().
|
static |
Definition at line 3534 of file TensorOps.cpp.
|
static |
Definition at line 3970 of file TensorOps.cpp.
|
static |
Definition at line 3978 of file TensorOps.cpp.
References mlir::isEqualConstantIntOrValue().
|
static |
Returns true if dimsPos
is invalid.
It is invalid when: a) It contains duplicate. b) At least one dimension is out of bound (dimPos
is >= 0 and < rank). c) The number of elements in dimsPos
is > than rank
.
Definition at line 3547 of file TensorOps.cpp.
|
static |
Definition at line 4026 of file TensorOps.cpp.
|
static |
Compute a TensorType that has the joined shape knowledge of the two given TensorTypes.
The element types need to match.
Definition at line 344 of file TensorOps.cpp.
References mlir::get(), mlir::TensorType::getElementType(), and mlir::TensorType::hasRank().
|
static |
Extract operands and shape from a tensor with dynamic extents.
Definition at line 1350 of file TensorOps.cpp.
References mlir::TensorType::getShape(), mlir::m_ConstantInt(), and mlir::matchPattern().
|
static |
Returns true if the pack op does not need a padding value.
Definition at line 3991 of file TensorOps.cpp.
ParseResult parseInferType | ( | OpAsmParser & | parser, |
std::optional< OpAsmParser::UnresolvedOperand > | optOperand, | ||
Type & | typeToInfer, | ||
Type | typeToInferFrom | ||
) |
Definition at line 2762 of file TensorOps.cpp.
References mlir::success().
void printInferType | ( | OpAsmPrinter & | printer, |
Operation * | op, | ||
Value | optOperand, | ||
Type | typeToInfer, | ||
Type | typeToInferFrom | ||
) |
Definition at line 2758 of file TensorOps.cpp.
|
static |
Definition at line 2063 of file TensorOps.cpp.
|
static |
Definition at line 3491 of file TensorOps.cpp.
|
static |
Try to remove a tensor operation if it would only reshape a constant.
Removes the op and replaces the constant with a new constant of the result shape.
Definition at line 1027 of file TensorOps.cpp.
References mlir::DenseElementsAttr::isSplat(), and mlir::DenseElementsAttr::resizeSplat().
|
static |
Definition at line 1241 of file TensorOps.cpp.
|
static |
Rank-reducing type verification for both InsertSliceOp and ParallelInsertSliceOp.
Definition at line 2445 of file TensorOps.cpp.
References mlir::isRankReducedType().
|
static |
Definition at line 1673 of file TensorOps.cpp.