[Mlir-commits] [mlir] [MLIR] Incorrect result for RuntimeVerifiableOpInterface on MemRef::R… (PR #96580)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Jun 25 10:40:49 PDT 2024
================
@@ -305,6 +305,40 @@ mlir::computeLinearIndex(OpFoldResult sourceOffset,
return {expr, values};
}
+std::pair<AffineExpr, SmallVector<OpFoldResult>>
+mlir::computeInclusiveLinearIndex(OpFoldResult sourceOffset,
+ ArrayRef<OpFoldResult> strides,
+ ArrayRef<OpFoldResult> indices) {
+ assert(strides.size() == indices.size());
+ auto sourceRank = static_cast<unsigned>(strides.size());
+
+ // Hold the affine symbols and values for the computation of the offset.
+ SmallVector<OpFoldResult> values(2 * sourceRank + 1);
+ SmallVector<AffineExpr> symbols(2 * sourceRank + 1);
+
+ bindSymbolsList(getContext(sourceOffset), MutableArrayRef{symbols});
+ AffineExpr expr = symbols.front();
+ AffineExpr constOneExpr = getAffineConstantExpr(1, getContext(sourceOffset));
+ values[0] = sourceOffset;
+
+ for (unsigned i = 0; i < sourceRank; ++i) {
+ // Compute the stride.
+ OpFoldResult origStride = strides[i];
+
+ // Build up the computation of the offset.
+ unsigned baseIdxForDim = 1 + 2 * i;
+ unsigned subOffsetForDim = baseIdxForDim;
+ unsigned origStrideForDim = baseIdxForDim + 1;
+ // Subtract 1 from the index to get the inclusive bound
+ expr = expr + (symbols[subOffsetForDim] - constOneExpr) *
----------------
hmalgewatta wrote:
Thanks for the feedback! I have made the corresponding changes in the next commit
https://github.com/llvm/llvm-project/pull/96580
More information about the Mlir-commits
mailing list