32 assert(((resType.getNumDynamicDims() == dynOutDims.size()) ||
33 dynOutDims.empty()) &&
34 "Either none or all output dynamic dims must be specified!");
43 for (
const auto [idx, val] :
enumerate(resType.getShape())) {
44 bool isDimDynamic = ShapedType::isDynamic(val);
45 bool updatePadHigh = !isDimDynamic || !dynOutDims.empty();
62 return b.
create<PadOp>(loc, resType, source, low, high, pad, nofold);
68 auto tensorTy = cast<RankedTensorType>(rankedTensor.
getType());
71 if (en.value() == ShapedType::kDynamic)
72 dynamicDims.push_back(
73 b.
create<tensor::DimOp>(loc, rankedTensor, en.index()));
78 FailureOr<RankedTensorType>
81 if (transposeVector.empty())
82 return rankedTensorType;
85 transposeVector.size() !=
static_cast<size_t>(rankedTensorType.getRank()))
92 RankedTensorType transposedTensorType =
93 RTTBuilder(rankedTensorType).
setShape(transposedShape);
94 return transposedTensorType;
98 llvm::SmallBitVector droppedDims = op.getDroppedDims();
100 RankedTensorType resultType = op.getDestType();
103 for (int64_t resultDim = 0; resultDim < resultType.getRank(); ++resultDim) {
104 if (droppedDims.test(resultDim)) {
107 if (resultType.getDimSize(resultDim) != 1)
112 {op.getSource(), srcDim}, {op.getResult(), resultDim});
113 if (failed(equalDimSize) || !*equalDimSize)
122 llvm::SmallBitVector droppedDims = op.getDroppedDims();
123 int64_t resultDim = 0;
126 RankedTensorType sourceType = op.getSourceType();
127 for (int64_t dim = 0, e = sourceType.getRank(); dim < e; ++dim) {
128 if (droppedDims.test(dim)) {
131 if (sourceType.getDimSize(dim) != 1)
136 {op.getSource(), dim}, {op.getResult(), resultDim});
137 if (failed(equalDimSize) || !*equalDimSize)
Base type for affine expression.
IntegerAttr getIndexAttr(int64_t value)
MLIRContext * getContext() const
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
This class helps build Operations.
Operation * create(const OperationState &state)
Creates an operation given the fields represented as an OperationState.
This class represents a single result from folding an operation.
This is a builder type that keeps local references to arguments.
Builder & setShape(ArrayRef< int64_t > newShape)
static FailureOr< bool > areEqual(const Variable &var1, const Variable &var2)
Compute whether the given variables are equal.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Type getType() const
Return the type of this value.
OpFoldResult makeComposedFoldedAffineApply(OpBuilder &b, Location loc, AffineMap map, ArrayRef< OpFoldResult > operands)
Constructs an AffineApplyOp that applies map to operands after composing the map with the maps of any...
constexpr void enumerate(std::tuple< Tys... > &tuple, CallbackT &&callback)
PadOp createPadHighOp(RankedTensorType resType, Value source, Value pad, bool nofold, Location loc, OpBuilder &builder, SmallVector< Value > dynOutDims={})
SmallVector< Value > createDynamicDimValues(OpBuilder &b, Location loc, Value rankedTensor)
bool isCastLikeInsertSliceOp(InsertSliceOp op)
A tensor.insert_slice is a cast-like operation if it merely rank-extends the source tensor or inserts...
bool isCastLikeExtractSliceOp(ExtractSliceOp op)
A tensor.extract_slice is a cast-like operation if it merely rank-reduces unit dimensions of the sour...
OpFoldResult getMixedSize(OpBuilder &builder, Location loc, Value value, int64_t dim)
Return the dimension of the given tensor value.
FailureOr< RankedTensorType > computeTransposedType(RankedTensorType rankedTensorType, ArrayRef< int64_t > transposeVector)
Returns the transposed rankedTensorType if transposeVector is non-empty.
Include the generated interface declarations.
void bindDims(MLIRContext *ctx, AffineExprTy &...exprs)
Bind a list of AffineExpr references to DimExpr at positions: [0 .
void applyPermutationToVector(SmallVector< T, N > &inVec, ArrayRef< int64_t > permutation)
Apply the permutation defined by permutation to inVec.
bool isPermutationVector(ArrayRef< int64_t > interchange)
Method to check if an interchange vector is a permutation.