#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 "llvm/ADT/DenseSet.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallBitVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/MathExtras.h"
#include <algorithm>
#include <optional>
usingnamespacemlir;
usingnamespacemlir::tensor;
divideCeilSigned;
divideFloorSigned;
mod;
Operation *TensorDialect::materializeConstant(OpBuilder &builder,
Attribute value, Type type,
Location loc) { … }
OpFoldResult tensor::getMixedSize(OpBuilder &builder, Location loc, Value value,
int64_t dim) { … }
SmallVector<OpFoldResult> tensor::getMixedSizes(OpBuilder &builder,
Location loc, Value value) { … }
FailureOr<Value> tensor::getOrCreateDestination(OpBuilder &b, Location loc,
OpResult opResult) { … }
LogicalResult tensor::getOrCreateDestinations(OpBuilder &b, Location loc,
Operation *op,
SmallVector<Value> &result) { … }
bool tensor::isSameTypeWithoutEncoding(Type tp1, Type tp2) { … }
static llvm::SmallBitVector getDroppedDims(ArrayRef<int64_t> reducedShape,
ArrayRef<OpFoldResult> mixedSizes) { … }
static RankedTensorType
foldDynamicToStaticDimSizes(RankedTensorType type, ValueRange dynamicSizes,
SmallVector<Value> &foldedDynamicSizes) { … }
bool BitcastOp::areCastCompatible(TypeRange inputs, TypeRange outputs) { … }
namespace {
struct ChainedTensorBitcast : public OpRewritePattern<BitcastOp> { … };
}
void BitcastOp::getCanonicalizationPatterns(RewritePatternSet &results,
MLIRContext *context) { … }
void CastOp::getAsmResultNames(function_ref<void(Value, StringRef)> setNameFn) { … }
bool mlir::tensor::preservesStaticInformation(Type source, Type target) { … }
bool mlir::tensor::canFoldIntoConsumerOp(CastOp castOp) { … }
bool mlir::tensor::canFoldIntoProducerOp(CastOp castOp) { … }
LogicalResult mlir::tensor::foldTensorCast(Operation *op) { … }
bool CastOp::areCastCompatible(TypeRange inputs, TypeRange outputs) { … }
static TensorType joinShapes(TensorType one, TensorType two) { … }
namespace {
struct ChainedTensorCast : public OpRewritePattern<CastOp> { … };
struct TensorCastExtractSlice : public OpRewritePattern<CastOp> { … };
}
void CastOp::getCanonicalizationPatterns(RewritePatternSet &results,
MLIRContext *context) { … }
RankedTensorType ConcatOp::inferResultType(int64_t dim, TypeRange inputTypes) { … }
void ConcatOp::build(OpBuilder &builder, OperationState &result, int64_t dim,
ValueRange inputs) { … }
LogicalResult ConcatOp::verify() { … }
LogicalResult
ConcatOp::reifyResultShapes(OpBuilder &builder,
ReifiedRankedShapedTypeDims &reifiedReturnShapes) { … }
void ConcatOp::getAsmResultNames(
function_ref<void(Value, StringRef)> setNameFn) { … }
OpFoldResult ConcatOp::fold(FoldAdaptor) { … }
namespace {
struct SingleInputConcatOp : public OpRewritePattern<ConcatOp> { … };
}
void ConcatOp::getCanonicalizationPatterns(RewritePatternSet &results,
MLIRContext *context) { … }
void DimOp::getAsmResultNames(function_ref<void(Value, StringRef)> setNameFn) { … }
void DimOp::build(OpBuilder &builder, OperationState &result, Value source,
int64_t index) { … }
std::optional<int64_t> DimOp::getConstantIndex() { … }
Speculation::Speculatability DimOp::getSpeculatability() { … }
OpFoldResult DimOp::fold(FoldAdaptor adaptor) { … }
namespace {
struct DimOfCastOp : public OpRewritePattern<DimOp> { … };
struct DimOfDestStyleOp : public OpRewritePattern<DimOp> { … };
struct DimOfReshapeOp : public OpRewritePattern<DimOp> { … };
}
void DimOp::getCanonicalizationPatterns(RewritePatternSet &results,
MLIRContext *context) { … }
void EmptyOp::build(OpBuilder &builder, OperationState &result,
ArrayRef<int64_t> staticShape, Type elementType,
Attribute encoding) { … }
void EmptyOp::build(OpBuilder &builder, OperationState &result,
ArrayRef<int64_t> staticShape, Type elementType,
ValueRange dynamicSizes, Attribute encoding) { … }
void EmptyOp::build(OpBuilder &builder, OperationState &result,
ArrayRef<OpFoldResult> sizes, Type elementType,
Attribute encoding) { … }
LogicalResult EmptyOp::verify() { … }
LogicalResult
EmptyOp::reifyResultShapes(OpBuilder &builder,
ReifiedRankedShapedTypeDims &reifiedReturnShapes) { … }
Value EmptyOp::getDynamicSize(unsigned idx) { … }
SmallVector<OpFoldResult> EmptyOp::getMixedSizes() { … }
namespace {
struct ReplaceEmptyTensorStaticShapeDims : OpRewritePattern<EmptyOp> { … };
struct FoldEmptyTensorWithDimOp : public OpRewritePattern<DimOp> { … };
struct FoldEmptyTensorWithCastOp : public OpRewritePattern<CastOp> { … };
}
void EmptyOp::getCanonicalizationPatterns(RewritePatternSet &results,
MLIRContext *context) { … }
static OpFoldResult
reshapeConstantSource(DenseElementsAttr source, TensorType result,
std::optional<Attribute> cst = std::nullopt) { … }
namespace {
struct ExtractFromTensorCast : public OpRewritePattern<tensor::ExtractOp> { … };
}
void ExtractOp::getAsmResultNames(
function_ref<void(Value, StringRef)> setNameFn) { … }
LogicalResult ExtractOp::verify() { … }
OpFoldResult ExtractOp::fold(FoldAdaptor adaptor) { … }
void ExtractOp::getCanonicalizationPatterns(RewritePatternSet &results,
MLIRContext *context) { … }
void FromElementsOp::getAsmResultNames(
function_ref<void(Value, StringRef)> setNameFn) { … }
void FromElementsOp::build(OpBuilder &builder, OperationState &result,
ValueRange elements) { … }
OpFoldResult FromElementsOp::fold(FoldAdaptor adaptor) { … }
namespace {
struct ExtractElementFromIndexCast
: public OpRewritePattern<tensor::ExtractOp> { … };
}
void FromElementsOp::getCanonicalizationPatterns(RewritePatternSet &results,
MLIRContext *context) { … }
void GatherOp::getAsmResultNames(
function_ref<void(Value, StringRef)> setNameFn) { … }
RankedTensorType GatherOp::inferResultType(RankedTensorType sourceType,
RankedTensorType indicesType,
ArrayRef<int64_t> gatherDims,
bool rankReduced) { … }
static LogicalResult
verifyGatherOrScatterDims(Operation *op, ArrayRef<int64_t> dims, int64_t rank,
StringRef gatherOrScatter, StringRef sourceOrDest) { … }
LogicalResult GatherOp::verify() { … }
OpFoldResult GatherOp::fold(FoldAdaptor adaptor) { … }
void InsertOp::getAsmResultNames(
function_ref<void(Value, StringRef)> setNameFn) { … }
LogicalResult InsertOp::verify() { … }
OpFoldResult InsertOp::fold(FoldAdaptor adaptor) { … }
void GenerateOp::getAsmResultNames(
function_ref<void(Value, StringRef)> setNameFn) { … }
LogicalResult GenerateOp::reifyResultShapes(
OpBuilder &builder, ReifiedRankedShapedTypeDims &reifiedReturnShapes) { … }
LogicalResult GenerateOp::verify() { … }
LogicalResult GenerateOp::verifyRegions() { … }
void GenerateOp::build(
OpBuilder &b, OperationState &result, Type resultTy,
ValueRange dynamicExtents,
function_ref<void(OpBuilder &, Location, ValueRange)> bodyBuilder) { … }
namespace {
struct StaticTensorGenerate : public OpRewritePattern<GenerateOp> { … };
struct ExtractFromTensorGenerate : public OpRewritePattern<tensor::ExtractOp> { … };
}
void GenerateOp::getCanonicalizationPatterns(RewritePatternSet &results,
MLIRContext *context) { … }
void RankOp::getAsmResultNames(function_ref<void(Value, StringRef)> setNameFn) { … }
OpFoldResult RankOp::fold(FoldAdaptor adaptor) { … }
void ReshapeOp::getAsmResultNames(
function_ref<void(Value, StringRef)> setNameFn) { … }
static int64_t getNumElements(ShapedType type) { … }
LogicalResult ReshapeOp::verify() { … }
OpFoldResult ReshapeOp::fold(FoldAdaptor adaptor) { … }
void CollapseShapeOp::getAsmResultNames(
function_ref<void(Value, StringRef)> setNameFn) { … }
void ExpandShapeOp::getAsmResultNames(
function_ref<void(Value, StringRef)> setNameFn) { … }
int64_t ExpandShapeOp::getCorrespondingSourceDim(int64_t resultDim) { … }
FailureOr<SmallVector<OpFoldResult>>
ExpandShapeOp::inferOutputShape(OpBuilder &b, Location loc,
RankedTensorType expandedType,
ArrayRef<ReassociationIndices> reassociation,
ArrayRef<OpFoldResult> inputShape) { … }
void ExpandShapeOp::build(OpBuilder &builder, OperationState &result,
Type resultType, Value src,
ArrayRef<ReassociationIndices> reassociation,
ArrayRef<OpFoldResult> outputShape) { … }
void ExpandShapeOp::build(OpBuilder &builder, OperationState &result,
Type resultType, Value src,
ArrayRef<ReassociationIndices> reassociation) { … }
SmallVector<AffineMap, 4> CollapseShapeOp::getReassociationMaps() { … }
SmallVector<ReassociationExprs, 4> CollapseShapeOp::getReassociationExprs() { … }
SmallVector<AffineMap, 4> ExpandShapeOp::getReassociationMaps() { … }
SmallVector<ReassociationExprs, 4> ExpandShapeOp::getReassociationExprs() { … }
RankedTensorType CollapseShapeOp::inferCollapsedType(
RankedTensorType type, SmallVector<ReassociationIndices> reassociation) { … }
RankedTensorType
CollapseShapeOp::inferCollapsedType(RankedTensorType type,
ArrayRef<AffineMap> reassociation) { … }
void CollapseShapeOp::build(OpBuilder &b, OperationState &result, Value src,
ArrayRef<ReassociationIndices> reassociation,
ArrayRef<NamedAttribute> attrs) { … }
template <typename TensorReshapeOp, bool isExpansion = std::is_same<
TensorReshapeOp, ExpandShapeOp>::value>
static LogicalResult verifyTensorReshapeOp(TensorReshapeOp op,
RankedTensorType expandedType,
RankedTensorType collapsedType) { … }
LogicalResult ExpandShapeOp::verify() { … }
LogicalResult CollapseShapeOp::verify() { … }
namespace {
template <typename TensorReshapeOp>
struct FoldReshapeWithConstant : OpRewritePattern<TensorReshapeOp> { … };
template <typename TensorReshapeOp>
class FoldReshapeWithSplat : public OpRewritePattern<TensorReshapeOp> { … };
template <typename TensorReshapeOp>
struct FoldReshapeWithFromElements : OpRewritePattern<TensorReshapeOp> { … };
struct FoldCollapseOfCastOp : public OpRewritePattern<CollapseShapeOp> { … };
struct FoldDimOfExpandShape : public OpRewritePattern<DimOp> { … };
struct FoldDimOfCollapseShape : public OpRewritePattern<DimOp> { … };
}
void ExpandShapeOp::getCanonicalizationPatterns(RewritePatternSet &results,
MLIRContext *context) { … }
void CollapseShapeOp::getCanonicalizationPatterns(RewritePatternSet &results,
MLIRContext *context) { … }
OpFoldResult ExpandShapeOp::fold(FoldAdaptor adaptor) { … }
OpFoldResult CollapseShapeOp::fold(FoldAdaptor adaptor) { … }
void ExtractSliceOp::getAsmResultNames(
function_ref<void(Value, StringRef)> setNameFn) { … }
RankedTensorType ExtractSliceOp::inferResultType(
RankedTensorType sourceTensorType, ArrayRef<int64_t> staticOffsets,
ArrayRef<int64_t> staticSizes, ArrayRef<int64_t> staticStrides) { … }
RankedTensorType ExtractSliceOp::inferResultType(
RankedTensorType sourceTensorType, ArrayRef<OpFoldResult> offsets,
ArrayRef<OpFoldResult> sizes, ArrayRef<OpFoldResult> strides) { … }
RankedTensorType ExtractSliceOp::inferCanonicalRankReducedResultType(
unsigned desiredResultRank, RankedTensorType sourceRankedTensorType,
ArrayRef<int64_t> offsets, ArrayRef<int64_t> sizes,
ArrayRef<int64_t> strides) { … }
RankedTensorType ExtractSliceOp::inferCanonicalRankReducedResultType(
unsigned desiredResultRank, RankedTensorType sourceRankedTensorType,
ArrayRef<OpFoldResult> offsets, ArrayRef<OpFoldResult> sizes,
ArrayRef<OpFoldResult> strides) { … }
void ExtractSliceOp::build(OpBuilder &b, OperationState &result,
RankedTensorType resultType, Value source,
ArrayRef<OpFoldResult> offsets,
ArrayRef<OpFoldResult> sizes,
ArrayRef<OpFoldResult> strides,
ArrayRef<NamedAttribute> attrs) { … }
void ExtractSliceOp::build(OpBuilder &b, OperationState &result, Value source,
ArrayRef<OpFoldResult> offsets,
ArrayRef<OpFoldResult> sizes,
ArrayRef<OpFoldResult> strides,
ArrayRef<NamedAttribute> attrs) { … }
void ExtractSliceOp::build(OpBuilder &b, OperationState &result, Value source,
ArrayRef<Range> ranges,
ArrayRef<NamedAttribute> attrs) { … }
void ExtractSliceOp::build(OpBuilder &b, OperationState &result,
RankedTensorType resultType, Value source,
ValueRange offsets, ValueRange sizes,
ValueRange strides, ArrayRef<NamedAttribute> attrs) { … }
void ExtractSliceOp::build(OpBuilder &b, OperationState &result, Value source,
ValueRange offsets, ValueRange sizes,
ValueRange strides, ArrayRef<NamedAttribute> attrs) { … }
static LogicalResult produceSliceErrorMsg(SliceVerificationResult result,
Operation *op,
RankedTensorType expectedType) { … }
LogicalResult ExtractSliceOp::verify() { … }
llvm::SmallBitVector ExtractSliceOp::getDroppedDims() { … }
FailureOr<Value>
ExtractSliceOp::rankReduceIfNeeded(OpBuilder &b, Location loc, Value value,
ArrayRef<int64_t> desiredShape) { … }
LogicalResult ExtractSliceOp::reifyResultShapes(
OpBuilder &builder, ReifiedRankedShapedTypeDims &reifiedReturnShapes) { … }
namespace {
class ExtractSliceOpCastFolder final : public OpRewritePattern<ExtractSliceOp> { … };
template <typename IterTy, typename ElemTy>
static void sliceElements(IterTy values, ArrayRef<int64_t> counts,
ArrayRef<int64_t> offsets, ArrayRef<int64_t> sizes,
ArrayRef<int64_t> strides,
llvm::SmallVectorImpl<ElemTy> *outValues) { … }
class ConstantOpExtractSliceFolder final
: public OpRewritePattern<ExtractSliceOp> { … };
}
void mlir::tensor::populateFoldConstantExtractSlicePatterns(
RewritePatternSet &patterns,
const ControlConstantExtractSliceFusionFn &controlFn) { … }
struct SliceReturnTypeCanonicalizer { … };
struct SliceCanonicalizer { … };
void ExtractSliceOp::getCanonicalizationPatterns(RewritePatternSet &results,
MLIRContext *context) { … }
static LogicalResult
foldIdentityOffsetSizeAndStrideOpInterface(OffsetSizeAndStrideOpInterface op,
ShapedType shapedType) { … }
static Value foldExtractAfterInsertSlice(ExtractSliceOp extractOp) { … }
OpFoldResult ExtractSliceOp::fold(FoldAdaptor adaptor) { … }
Value mlir::tensor::createCanonicalRankReducingExtractSliceOp(
OpBuilder &b, Location loc, Value tensor, RankedTensorType targetType) { … }
void InsertSliceOp::getAsmResultNames(
function_ref<void(Value, StringRef)> setNameFn) { … }
void InsertSliceOp::build(OpBuilder &b, OperationState &result, Value source,
Value dest, ArrayRef<OpFoldResult> offsets,
ArrayRef<OpFoldResult> sizes,
ArrayRef<OpFoldResult> strides,
ArrayRef<NamedAttribute> attrs) { … }
void InsertSliceOp::build(OpBuilder &b, OperationState &result, Value source,
Value dest, ArrayRef<Range> ranges,
ArrayRef<NamedAttribute> attrs) { … }
void InsertSliceOp::build(OpBuilder &b, OperationState &result, Value source,
Value dest, ValueRange offsets, ValueRange sizes,
ValueRange strides, ArrayRef<NamedAttribute> attrs) { … }
static SliceVerificationResult verifyInsertSliceOp(
RankedTensorType srcType, RankedTensorType dstType,
ArrayRef<int64_t> staticOffsets, ArrayRef<int64_t> staticSizes,
ArrayRef<int64_t> staticStrides, RankedTensorType *expectedType = nullptr) { … }
LogicalResult InsertSliceOp::verify() { … }
static LogicalResult foldInsertAfterInsertSlice(InsertSliceOp insertOp) { … }
static Value foldInsertAfterExtractSlice(InsertSliceOp insertOp) { … }
OpFoldResult InsertSliceOp::fold(FoldAdaptor) { … }
LogicalResult InsertSliceOp::reifyResultShapes(
OpBuilder &builder, ReifiedRankedShapedTypeDims &reifiedReturnShapes) { … }
namespace {
template <typename InsertOpTy>
class InsertSliceOpConstantArgumentFolder final
: public OpRewritePattern<InsertOpTy> { … };
template <typename InsertOpTy>
struct InsertSliceOpCastFolder final : public OpRewritePattern<InsertOpTy> { … };
template <typename InsertOpTy>
struct InsertSliceOpSourceCastInserter final
: public OpRewritePattern<InsertOpTy> { … };
}
llvm::SmallBitVector InsertSliceOp::getDroppedDims() { … }
void InsertSliceOp::getCanonicalizationPatterns(RewritePatternSet &results,
MLIRContext *context) { … }
Value mlir::tensor::createCanonicalRankReducingInsertSliceOp(OpBuilder &b,
Location loc,
Value tensor,
Value dest) { … }
void PadOp::getAsmResultNames(function_ref<void(Value, StringRef)> setNameFn) { … }
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) { … }
LogicalResult PadOp::verify() { … }
LogicalResult PadOp::verifyRegions() { … }
RankedTensorType PadOp::inferResultType(RankedTensorType sourceType,
ArrayRef<int64_t> staticLow,
ArrayRef<int64_t> staticHigh,
ArrayRef<int64_t> resultShape) { … }
void PadOp::build(OpBuilder &b, OperationState &result, Type resultType,
Value source, ArrayRef<int64_t> staticLow,
ArrayRef<int64_t> staticHigh, ValueRange low, ValueRange high,
bool nofold, ArrayRef<NamedAttribute> attrs) { … }
void PadOp::build(OpBuilder &b, OperationState &result, Type resultType,
Value source, ValueRange low, ValueRange high, bool nofold,
ArrayRef<NamedAttribute> attrs) { … }
void PadOp::build(OpBuilder &b, OperationState &result, Type resultType,
Value source, ArrayRef<OpFoldResult> low,
ArrayRef<OpFoldResult> high, bool nofold,
ArrayRef<NamedAttribute> attrs) { … }
void PadOp::build(OpBuilder &b, OperationState &result, Type resultType,
Value source, ArrayRef<OpFoldResult> low,
ArrayRef<OpFoldResult> high, Value constantPadValue,
bool nofold, ArrayRef<NamedAttribute> attrs) { … }
llvm::SmallBitVector PadOp::getPaddedDims() { … }
namespace {
struct FoldStaticZeroPadding : public OpRewritePattern<PadOp> { … };
struct FoldSourceTensorCast : public OpRewritePattern<PadOp> { … };
struct FoldTargetTensorCast : public OpRewritePattern<PadOp> { … };
struct FoldOrthogonalPaddings : public OpRewritePattern<PadOp> { … };
struct FoldStaticPadding : public OpRewritePattern<PadOp> { … };
}
void PadOp::getCanonicalizationPatterns(RewritePatternSet &results,
MLIRContext *context) { … }
Value PadOp::getConstantPaddingValue() { … }
OpFoldResult PadOp::fold(FoldAdaptor) { … }
OpResult ParallelInsertSliceOp::getTiedOpResult() { … }
void ParallelInsertSliceOp::build(OpBuilder &b, OperationState &result,
Value source, Value dest,
ArrayRef<OpFoldResult> offsets,
ArrayRef<OpFoldResult> sizes,
ArrayRef<OpFoldResult> strides,
ArrayRef<NamedAttribute> attrs) { … }
void ParallelInsertSliceOp::build(OpBuilder &b, OperationState &result,
Value source, Value dest,
ArrayRef<Range> ranges,
ArrayRef<NamedAttribute> attrs) { … }
void ParallelInsertSliceOp::build(OpBuilder &b, OperationState &result,
Value source, Value dest, ValueRange offsets,
ValueRange sizes, ValueRange strides,
ArrayRef<NamedAttribute> attrs) { … }
LogicalResult ParallelInsertSliceOp::verify() { … }
void ParallelInsertSliceOp::getCanonicalizationPatterns(
RewritePatternSet &results, MLIRContext *context) { … }
llvm::SmallBitVector ParallelInsertSliceOp::getDroppedDims() { … }
void ScatterOp::getAsmResultNames(
function_ref<void(Value, StringRef)> setNameFn) { … }
LogicalResult ScatterOp::verify() { … }
void SplatOp::build(OpBuilder &builder, OperationState &result, Value element,
Type aggregateType, ValueRange dynamicSizes) { … }
void SplatOp::build(OpBuilder &builder, OperationState &result, Value element,
ArrayRef<int64_t> staticShape, ValueRange dynamicSizes) { … }
void SplatOp::build(OpBuilder &builder, OperationState &result, Value element,
ArrayRef<OpFoldResult> sizes) { … }
void SplatOp::getAsmResultNames(
function_ref<void(Value, StringRef)> setNameFn) { … }
LogicalResult SplatOp::verify() { … }
LogicalResult
SplatOp::reifyResultShapes(OpBuilder &builder,
ReifiedRankedShapedTypeDims &reifiedReturnShapes) { … }
OpFoldResult SplatOp::fold(FoldAdaptor adaptor) { … }
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) { … }
static bool areAllInBound(ArrayRef<int64_t> sourceShape,
ArrayRef<int64_t> limitShape) { … }
template <typename OpTy>
static LogicalResult commonVerifierPackAndUnPackOp(OpTy packOrUnPack) { … }
namespace {
struct PackOrUnPackTransposeResult { … };
}
template <typename OpTy>
static PackOrUnPackTransposeResult
commonPermutationOfPackAndUnPackOp(OpTy packOrUnPackOp,
ArrayRef<int64_t> innerPermutation,
ArrayRef<int64_t> outerPermutation) { … }
void PackOp::getAsmResultNames(function_ref<void(Value, StringRef)> setNameFn) { … }
void PackOp::build(OpBuilder &builder, OperationState &state, Value source,
Value dest, ArrayRef<int64_t> innerDimsPos,
ArrayRef<OpFoldResult> innerTiles,
std::optional<Value> paddingValue,
ArrayRef<int64_t> outerDimsPerm) { … }
LogicalResult
PackOp::reifyResultShapes(OpBuilder &builder,
ReifiedRankedShapedTypeDims &reifiedReturnShapes) { … }
DenseMap<int64_t, OpFoldResult> PackOp::getDimAndTileMapping() { … }
SmallVector<OpFoldResult> PackOp::getMixedTiles() { … }
SmallVector<int64_t> PackOp::getStaticTiles() { … }
bool PackOp::requirePaddingValue(ArrayRef<int64_t> inputShape,
ArrayRef<int64_t> innerDimsPos,
ArrayRef<int64_t> outputShape,
ArrayRef<int64_t> outerDimsPerm,
ArrayRef<OpFoldResult> innerTiles) { … }
LogicalResult PackOp::verify() { … }
static SmallVector<int64_t>
asShapeWithAnyValueAsDynamic(ArrayRef<OpFoldResult> ofrs) { … }
static SmallVector<int64_t> getPackOpResultTypeShape(
ArrayRef<int64_t> sourceShape, ArrayRef<int64_t> innerTileSizes,
ArrayRef<int64_t> innerDimsPos, ArrayRef<int64_t> outerDimsPerm) { … }
SmallVector<OpFoldResult> PackOp::getResultShape(
OpBuilder &builder, Location loc, ArrayRef<OpFoldResult> sourceDims,
ArrayRef<OpFoldResult> innerTileSizes, ArrayRef<int64_t> innerDimsPos,
ArrayRef<int64_t> outerDimsPerm) { … }
RankedTensorType PackOp::inferPackedType(RankedTensorType sourceType,
ArrayRef<int64_t> innerTileSizes,
ArrayRef<int64_t> innerDimsPos,
ArrayRef<int64_t> outerDimsPerm) { … }
Value PackOp::createDestinationTensor(OpBuilder &b, Location loc, Value source,
ArrayRef<OpFoldResult> innerTileSizes,
ArrayRef<int64_t> innerDimsPos,
ArrayRef<int64_t> outerDimsPerm) { … }
PackOp PackOp::createTransposedClone(OpBuilder &b, Location loc,
ArrayRef<int64_t> innerPermutation,
ArrayRef<int64_t> outerPermutation) { … }
template <typename OpTy>
bool areTilesAndTiledDimsAllConstant(OpTy op) { … }
Speculation::Speculatability PackOp::getSpeculatability() { … }
static bool hasSameInnerOuterAttribute(PackOp packOp, UnPackOp unPackOp) { … }
static bool haveSameTiles(PackOp packOp, UnPackOp unPackOp) { … }
static bool paddingIsNotNeeded(PackOp op) { … }
static bool inferStaticShape(PackOp packOp, SmallVectorImpl<int64_t> &srcShape,
SmallVectorImpl<int64_t> &destShape) { … }
LogicalResult PackOp::canonicalize(PackOp packOp, PatternRewriter &rewriter) { … }
template <typename PackOrUnpackOp>
static bool isLikePadUnPad(PackOrUnpackOp packOp,
RankedTensorType packedTensorType) { … }
bool PackOp::isLikePad() { … }
OpFoldResult PackOp::fold(FoldAdaptor adaptor) { … }
void UnPackOp::getAsmResultNames(
function_ref<void(Value, StringRef)> setNameFn) { … }
LogicalResult
UnPackOp::reifyResultShapes(OpBuilder &builder,
ReifiedRankedShapedTypeDims &reifiedReturnShapes) { … }
DenseMap<int64_t, OpFoldResult> UnPackOp::getDimAndTileMapping() { … }
SmallVector<OpFoldResult> UnPackOp::getMixedTiles() { … }
SmallVector<int64_t> UnPackOp::getStaticTiles() { … }
LogicalResult UnPackOp::verify() { … }
Speculation::Speculatability UnPackOp::getSpeculatability() { … }
void UnPackOp::build(OpBuilder &builder, OperationState &state, Value source,
Value dest, ArrayRef<int64_t> innerDimsPos,
ArrayRef<OpFoldResult> innerTiles,
ArrayRef<int64_t> outerDimsPerm) { … }
Value UnPackOp::createDestinationTensor(OpBuilder &b, Location loc,
Value source,
ArrayRef<OpFoldResult> innerTileSizes,
ArrayRef<int64_t> innerDimsPos,
ArrayRef<int64_t> outerDimsPerm) { … }
UnPackOp UnPackOp::createTransposedClone(OpBuilder &b, Location loc,
Value transposedSource,
ArrayRef<int64_t> innerPermutation,
ArrayRef<int64_t> outerPermutation) { … }
static bool inferStaticShape(UnPackOp op, SmallVectorImpl<int64_t> &srcShape,
SmallVectorImpl<int64_t> &destShape) { … }
LogicalResult UnPackOp::canonicalize(UnPackOp unPackOp,
PatternRewriter &rewriter) { … }
bool UnPackOp::isLikeUnPad() { … }
OpFoldResult UnPackOp::fold(FoldAdaptor adaptor) { … }
struct FoldTensorCastProducerOp
: public OpInterfaceRewritePattern<DestinationStyleOpInterface> { … };
void TensorDialect::getCanonicalizationPatterns(
RewritePatternSet &results) const { … }
#define GET_OP_CLASSES
#include "mlir/Dialect/Tensor/IR/TensorOps.cpp.inc"