#include "mlir/Dialect/Utils/ReshapeOpsUtils.h"
#include "mlir/IR/AffineMap.h"
#include "mlir/IR/Builders.h"
#include <numeric>
#include <optional>
usingnamespacemlir;
std::optional<SmallVector<ReassociationIndices>>
mlir::getReassociationIndicesForReshape(ShapedType sourceType,
ShapedType targetType) { … }
std::optional<SmallVector<ReassociationIndices>>
mlir::getReassociationIndicesForCollapse(ArrayRef<int64_t> sourceShape,
ArrayRef<int64_t> targetShape) { … }
std::optional<SmallVector<ReassociationIndices>>
mlir::composeReassociationIndices(
ArrayRef<ReassociationIndices> producerReassociations,
ArrayRef<ReassociationIndices> consumerReassociations,
MLIRContext *context) { … }
SmallVector<SmallVector<AffineExpr, 2>, 2>
mlir::convertReassociationIndicesToExprs(
MLIRContext *context, ArrayRef<ReassociationIndices> reassociationIndices) { … }
template <typename AffineExprTy>
unsigned getMaxPosOfType(ArrayRef<ReassociationExprs> exprArrays) { … }
ArrayAttr mlir::getReassociationIndicesAttribute(
OpBuilder &b, ArrayRef<ReassociationIndices> reassociation) { … }
SmallVector<ReassociationIndices, 2> mlir::convertReassociationMapsToIndices(
ArrayRef<ReassociationExprs> reassociationExprs) { … }
SmallVector<AffineMap, 4>
mlir::getSymbolLessAffineMaps(ArrayRef<ReassociationExprs> reassociation) { … }
bool mlir::isReassociationValid(ArrayRef<AffineMap> reassociation,
int *invalidIndex) { … }
LogicalResult mlir::reshapeLikeShapesAreCompatible(
function_ref<LogicalResult(const Twine &)> emitError,
ArrayRef<int64_t> collapsedShape, ArrayRef<int64_t> expandedShape,
ArrayRef<ReassociationIndices> reassociationMaps, bool isExpandingReshape) { … }
bool mlir::hasNonIdentityLayout(Type type) { … }
llvm::SmallBitVector
mlir::getSlicedDimensions(ArrayRef<OpFoldResult> sliceInputShape,
ArrayRef<Range> sliceParams) { … }
llvm::SmallBitVector mlir::getLinearizedDimensions(
ArrayRef<ReassociationIndices> reassociationIndices) { … }
SmallVector<Range> SliceFromCollapseHelper::getExtractSliceParams(
MLIRContext *ctx, ArrayRef<ValueRange> multiIndices) { … }
SmallVector<Range>
SliceFromCollapseHelper::getInsertSliceParams(MLIRContext *ctx,
ValueRange tileIndices) { … }
static std::optional<int64_t> getUniqueNonUnitDim(ArrayRef<int64_t> indices,
ArrayRef<int64_t> shape) { … }
static SmallVector<std::optional<int64_t>> getCollapseShapeTrivialSegments(
RankedTensorType sourceType,
ArrayRef<ReassociationIndices> reassociationIndices) { … }
static FailureOr<SmallVector<std::optional<int64_t>>>
canCollapseShapeBeSimplifiedByRankReducingSlice(
RankedTensorType sourceType,
ArrayRef<ReassociationIndices> reassociationIndices) { … }
FailureOr<CollapseShapeRankReducingSliceSimplificationInfo>
mlir::getSimplifyCollapseShapeWithRankReducingSliceInfo(
RankedTensorType sourceType,
ArrayRef<ReassociationIndices> reassociationIndices) { … }
PackingMetadata mlir::computePackingMetadata(int64_t packedRank,
ArrayRef<int64_t> innerDimPos) { … }