[Mlir-commits] [mlir] [mlir][sparse] Update verifier for block sparsity and singleton (PR #69389)

Peiming Liu llvmlistbot at llvm.org
Wed Oct 18 11:34:52 PDT 2023


================
@@ -663,6 +666,17 @@ SparseTensorEncodingAttr::verify(function_ref<InFlightDiagnostic()> emitError,
     return emitError() << "unexpected position bitwidth: " << posWidth;
   if (!acceptBitWidth(crdWidth))
     return emitError() << "unexpected coordinate bitwidth: " << crdWidth;
+  if (auto it = std::find_if(lvlTypes.begin(), lvlTypes.end(), isSingletonDLT);
+      it != std::end(lvlTypes)) {
+    if (it == lvlTypes.begin() ||
+        (!isCompressedDLT(*(it - 1)) && !isLooseCompressedDLT(*(it - 1))))
+      return emitError() << "expected compressed or loose_compressed level "
+                            "before singleton level";
----------------
PeimingLiu wrote:

I *personally* follow the convention that whenever the single statement body spans multiple lines and/or the complex condition statement spans multiple lines, I added the brace. But as Mehdi suggested, it is not a fixed rule.

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


More information about the Mlir-commits mailing list