38 b.setInsertionPoint(padOp);
42 Value constantPadding = padOp.getConstantPaddingValue();
51 newMixedLow.push_back(*
ub);
57 newMixedHigh.push_back(*
ub);
61 if (llvm::equal(padOp.getMixedLowPad(), newMixedLow) &&
62 llvm::equal(padOp.getMixedHighPad(), newMixedHigh))
63 return padOp.getResult();
67 PadOp::create(
b, loc, padOp.getResultType(), padOp.getSource(),
68 newMixedLow, newMixedHigh, constantPadding,
74 ReifyRankedShapedTypeOpInterface reifyShapedTypeInterface =
75 dyn_cast<ReifyRankedShapedTypeOpInterface>(padOp.getOperation());
76 if (failed(reifyShapedTypeInterface.reifyResultShapes(
b, reifiedSizes)))
79 for (
int64_t i = 0, e = padOp.getResultType().getRank(); i < e; ++i) {
82 if (isa<Attribute>(prevLow)) {
83 offsets.push_back(
b.getIndexAttr(0));
86 affine::AffineApplyOp::create(
87 b, loc,
b.getAffineDimExpr(0) -
b.getAffineDimExpr(1),
88 std::initializer_list<Value>{cast<Value>(newMixedLow[i]),
89 cast<Value>(prevLow)})
93 if (!padOp.getResultType().isDynamicDim(i)) {
94 sizes.push_back(
b.getIndexAttr(padOp.getResultType().getDimSize(i)));
96 sizes.push_back(reifiedSizes[0][i]);
99 strides.push_back(
b.getIndexAttr(1));
102 return ExtractSliceOp::create(
b, loc, newPadOp, offsets, sizes, strides)
107 tensor::EmptyOp emptyOp,
110 b.setInsertionPoint(emptyOp);
118 newSizes.push_back(*
ub);
122 if (llvm::equal(emptyOp.getMixedSizes(), newSizes))
123 return emptyOp.getResult();
127 EmptyOp::create(
b, loc, newSizes, emptyOp.getType().getElementType());
132 return ExtractSliceOp::create(
b, loc, newEmptyOp, offsets,
133 emptyOp.getMixedSizes(), strides)
static LogicalResult computeIndependentBound(AffineMap &resultMap, ValueDimList &mapOperands, presburger::BoundType type, const Variable &var, ValueRange independencies, ValueBoundsOptions options={})
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.