24 if (isa<Attribute>(ofr))
26 Value value = cast<Value>(ofr);
44 Value constantPadding = padOp.getConstantPaddingValue();
53 newMixedLow.push_back(*ub);
59 newMixedHigh.push_back(*ub);
63 if (llvm::equal(padOp.getMixedLowPad(), newMixedLow) &&
64 llvm::equal(padOp.getMixedHighPad(), newMixedHigh))
65 return padOp.getResult();
68 auto newPadOp = b.
create<PadOp>(
69 loc, padOp.getResultType(), padOp.getSource(), newMixedLow, newMixedHigh,
75 ReifyRankedShapedTypeOpInterface reifyShapedTypeInterface =
76 dyn_cast<ReifyRankedShapedTypeOpInterface>(padOp.getOperation());
77 if (failed(reifyShapedTypeInterface.reifyResultShapes(b, reifiedSizes)))
80 for (int64_t i = 0, e = padOp.getResultType().getRank(); i < e; ++i) {
83 if (isa<Attribute>(prevLow)) {
87 b.
create<affine::AffineApplyOp>(
89 std::initializer_list<Value>{cast<Value>(newMixedLow[i]),
90 cast<Value>(prevLow)})
94 if (!padOp.getResultType().isDynamicDim(i)) {
95 sizes.push_back(b.
getIndexAttr(padOp.getResultType().getDimSize(i)));
97 sizes.push_back(reifiedSizes[0][i]);
103 return b.
create<ExtractSliceOp>(loc, newPadOp, offsets, sizes, strides)
108 tensor::EmptyOp emptyOp,
119 newSizes.push_back(*ub);
123 if (llvm::equal(emptyOp.getMixedSizes(), newSizes))
124 return emptyOp.getResult();
128 b.
create<EmptyOp>(loc, newSizes, emptyOp.getType().getElementType());
134 .
create<ExtractSliceOp>(loc, newEmptyOp, offsets, emptyOp.getMixedSizes(),
A multi-dimensional affine map Affine map's are immutable like Type's, and they are uniqued.
IntegerAttr getIndexAttr(int64_t value)
AffineExpr getAffineDimExpr(unsigned position)
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
RAII guard to reset the insertion point of the builder when destroyed.
This class helps build Operations.
void setInsertionPoint(Block *block, Block::iterator insertPoint)
Set the insertion point to the specified location.
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.
OpResult getResult(unsigned idx)
Get the 'idx'th result of this operation.
static LogicalResult computeIndependentBound(AffineMap &resultMap, ValueDimList &mapOperands, presburger::BoundType type, const Variable &var, ValueRange independencies, bool closedUB=false)
Compute a bound in that is independent of all values in independencies.
This class provides an abstraction over the different types of ranges over Values.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
OpFoldResult materializeComputedBound(OpBuilder &b, Location loc, AffineMap boundMap, ArrayRef< std::pair< Value, std::optional< int64_t >>> mapOperands)
Materialize an already computed bound with Affine dialect ops.
FailureOr< Value > buildIndependentOp(OpBuilder &b, tensor::PadOp padOp, ValueRange independencies)
Build a new tensor::PadOp with low/high padding that is independent of all given independencies.
Include the generated interface declarations.
SmallVector< std::pair< Value, std::optional< int64_t > >> ValueDimList