39 b.setInsertionPoint(padOp);
43 Value constantPadding = padOp.getConstantPaddingValue();
52 newMixedLow.push_back(*
ub);
58 newMixedHigh.push_back(*
ub);
62 if (llvm::equal(padOp.getMixedLowPad(), newMixedLow) &&
63 llvm::equal(padOp.getMixedHighPad(), newMixedHigh))
64 return padOp.getResult();
68 PadOp::create(
b, loc, padOp.getResultType(), padOp.getSource(),
69 newMixedLow, newMixedHigh, constantPadding,
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)) {
84 offsets.push_back(
b.getIndexAttr(0));
87 affine::AffineApplyOp::create(
88 b, loc,
b.getAffineDimExpr(0) -
b.getAffineDimExpr(1),
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]);
100 strides.push_back(
b.getIndexAttr(1));
103 return ExtractSliceOp::create(
b, loc, newPadOp, offsets, sizes, strides)
108 tensor::EmptyOp emptyOp,
111 b.setInsertionPoint(emptyOp);
119 newSizes.push_back(*
ub);
123 if (llvm::equal(emptyOp.getMixedSizes(), newSizes))
124 return emptyOp.getResult();
128 EmptyOp::create(
b, loc, newSizes, emptyOp.getType().getElementType());
133 return ExtractSliceOp::create(
b, loc, newEmptyOp, offsets,
134 emptyOp.getMixedSizes(), strides)
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.
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.