[Mlir-commits] [mlir] [mlir][sparse]Make isBlockSparsity more robust (PR #75113)

Aart Bik llvmlistbot at llvm.org
Mon Dec 11 16:22:12 PST 2023


================
@@ -878,12 +879,21 @@ bool mlir::sparse_tensor::isBlockSparsity(AffineMap dimToLvl) {
         // Expect mod to have the same coefficient as floordiv.
         if (conOp.getValue() != coeffientMap[pos])
           return false;
+        hasBlock = true;
       } else {
         return false;
       }
+    } else if (auto dimOp = dyn_cast<AffineDimExpr>(result)) {
+      auto pos = dimOp.getPosition();
+      // Expect dim to be unset.
+      if (coeffientMap.find(pos) != coeffientMap.end())
+        return false;
+      coeffientMap[pos] = 0;
+    } else {
+      return false;
     }
   }
-  return !coeffientMap.empty();
+  return !coeffientMap.empty() && hasBlock;
----------------
aartbik wrote:

just hasBlock suffices now

https://github.com/llvm/llvm-project/pull/75113


More information about the Mlir-commits mailing list