[Mlir-commits] [mlir] [mlir][sparse] connect MapRef's lvl2dim with latest AffineMap computation (PR #69540)
Aart Bik
llvmlistbot at llvm.org
Wed Oct 18 17:57:42 PDT 2023
================
@@ -751,6 +744,35 @@ Value sparse_tensor::genMapBuffers(OpBuilder &builder, Location loc,
}
lvlSizesValues[l] = lvlSz;
}
+ // Generate lvl2dim.
+ assert(dimRank == lvlToDim.getNumResults());
+ for (Dimension d = 0; d < dimRank; d++) {
+ AffineExpr exp = lvlToDim.getResult(d);
+ // We expect:
+ // (1) d = l
+ // (2) d = l' * c + l
+ Level l = 0, ll = 0;
+ uint64_t c = 0;
+ switch (exp.getKind()) {
+ case AffineExprKind::DimId: {
+ l = exp.cast<AffineDimExpr>().getPosition();
+ break;
+ }
+ case AffineExprKind::Add: {
+ // Always mul on lhs, symbol/constant on rhs.
+ auto add = exp.cast<AffineBinaryOpExpr>();
+ assert(add.getLHS().getKind() == AffineExprKind::Mul);
----------------
aartbik wrote:
Yeah, the AffineExpr always make LHS the more compound one. I am guessing for cases like this ;-)
https://github.com/llvm/llvm-project/pull/69540
More information about the Mlir-commits
mailing list