Skip to content

Commit 35d05d4

Browse files
committed
Fix linking issue
1 parent 9037714 commit 35d05d4

File tree

2 files changed

+27
-23
lines changed

2 files changed

+27
-23
lines changed

mlir/lib/Dialect/Affine/IR/AffineOps.cpp

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5022,6 +5022,31 @@ SmallVector<OpFoldResult> AffineLinearizeIndexOp::getPaddedBasis() {
50225022
return ret;
50235023
}
50245024

5025+
namespace mlir {
5026+
namespace affine {
5027+
OpFoldResult computeProduct(Location loc, OpBuilder &builder,
5028+
ArrayRef<OpFoldResult> terms) {
5029+
int64_t nDynamic = 0;
5030+
SmallVector<Value> dynamicPart;
5031+
AffineExpr result = builder.getAffineConstantExpr(1);
5032+
for (OpFoldResult term : terms) {
5033+
if (!term)
5034+
return term;
5035+
std::optional<int64_t> maybeConst = getConstantIntValue(term);
5036+
if (maybeConst) {
5037+
result = result * builder.getAffineConstantExpr(*maybeConst);
5038+
} else {
5039+
dynamicPart.push_back(cast<Value>(term));
5040+
result = result * builder.getAffineSymbolExpr(nDynamic++);
5041+
}
5042+
}
5043+
if (auto constant = dyn_cast<AffineConstantExpr>(result))
5044+
return getAsIndexOpFoldResult(builder.getContext(), constant.getValue());
5045+
return builder.create<AffineApplyOp>(loc, result, dynamicPart).getResult();
5046+
}
5047+
} // namespace affine
5048+
} // namespace mlir
5049+
50255050
namespace {
50265051
/// Rewrite `affine.linearize_index disjoint [%...a, %x, %...b] by (%...c, 1,
50275052
/// %...d)` to `affine.linearize_index disjoint [%...a, %...b] by (%...c,
@@ -5081,27 +5106,6 @@ struct DropLinearizeUnitComponentsIfDisjointOrZero final
50815106
}
50825107
};
50835108

5084-
OpFoldResult computeProduct(Location loc, OpBuilder &builder,
5085-
ArrayRef<OpFoldResult> terms) {
5086-
int64_t nDynamic = 0;
5087-
SmallVector<Value> dynamicPart;
5088-
AffineExpr result = builder.getAffineConstantExpr(1);
5089-
for (OpFoldResult term : terms) {
5090-
if (!term)
5091-
return term;
5092-
std::optional<int64_t> maybeConst = getConstantIntValue(term);
5093-
if (maybeConst) {
5094-
result = result * builder.getAffineConstantExpr(*maybeConst);
5095-
} else {
5096-
dynamicPart.push_back(cast<Value>(term));
5097-
result = result * builder.getAffineSymbolExpr(nDynamic++);
5098-
}
5099-
}
5100-
if (auto constant = dyn_cast<AffineConstantExpr>(result))
5101-
return getAsIndexOpFoldResult(builder.getContext(), constant.getValue());
5102-
return builder.create<AffineApplyOp>(loc, result, dynamicPart).getResult();
5103-
}
5104-
51055109
/// If conseceutive outputs of a delinearize_index are linearized with the same
51065110
/// bounds, canonicalize away the redundant arithmetic.
51075111
///
@@ -5248,7 +5252,7 @@ struct CancelLinearizeOfDelinearizePortion final
52485252
// We use the slice from the linearize's basis above because of the
52495253
// "bounds inferred from `disjoint`" case above.
52505254
OpFoldResult newSize =
5251-
computeProduct(linearizeOp.getLoc(), rewriter, basisToMerge);
5255+
affine::computeProduct(linearizeOp.getLoc(), rewriter, basisToMerge);
52525256

52535257
// Trivial case where we can just skip past the delinearize all together
52545258
if (m.length == m.delinearize.getNumResults()) {

mlir/lib/Dialect/MemRef/Transforms/FlattenMemRefs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ getFlatOffsetAndStrides(OpBuilder &rewriter, Location loc, Value source,
103103

104104
// Compute collapsed size: (the outmost stride * outmost dimension).
105105
SmallVector<OpFoldResult> ops{origStrides.front(), outmostDim};
106-
OpFoldResult collapsedSize = computeProduct(loc, rewriter, ops);
106+
OpFoldResult collapsedSize = affine::computeProduct(loc, rewriter, ops);
107107

108108
return {newExtractStridedMetadata.getBaseBuffer(), linearizedIndex,
109109
origStrides, origOffset, collapsedSize};

0 commit comments

Comments
 (0)