[Mlir-commits] [mlir] [MLIR] Fixing the memref linearization size computation for non-packed memref (PR #138922)
Krzysztof Drewniak
llvmlistbot at llvm.org
Thu May 8 08:54:19 PDT 2025
================
@@ -75,18 +74,31 @@ std::pair<LinearizedMemRefInfo, OpFoldResult> getLinearizedMemRefOffsetAndSize(
addMulMap = addMulMap + symbols[offsetIdx] * symbols[offsetIdx + 1];
offsetValues[offsetIdx] = indicesVec[i];
offsetValues[offsetIdx + 1] = strides[i];
-
- mulMap = mulMap * symbols[i];
}
-
// Adjust linearizedIndices and size by the scale factor (dstBits / srcBits).
int64_t scaler = dstBits / srcBits;
- mulMap = mulMap.floorDiv(scaler);
-
OpFoldResult linearizedIndices = affine::makeComposedFoldedAffineApply(
builder, loc, addMulMap.floorDiv(scaler), offsetValues);
+
+ size_t symbolIndex = 0;
+ SmallVector<OpFoldResult> values;
+ SmallVector<AffineExpr> productExpressions;
+ for (unsigned i = 0; i < sourceRank; ++i) {
+ AffineExpr strideExpr = symbols[symbolIndex++];
+ OpFoldResult stride = strides[i];
+ values.push_back(getValueOrCreateConstantIndexOp(builder, loc, stride));
+
+ AffineExpr sizeExpr = symbols[symbolIndex++];
+ OpFoldResult size = sizes[i];
+ values.push_back(getValueOrCreateConstantIndexOp(builder, loc, size));
----------------
krzysz00 wrote:
```suggestion
values.push_back(sizes[i]);
```
https://github.com/llvm/llvm-project/pull/138922
More information about the Mlir-commits
mailing list