[mlir][sparse][taco] Avoid hard-coding DimLevelType values.
authorbixia1 <bixia@google.com>
Sun, 2 Oct 2022 14:53:59 +0000 (07:53 -0700)
committerbixia1 <bixia@google.com>
Mon, 3 Oct 2022 17:02:57 +0000 (10:02 -0700)
Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D135034

mlir/test/Integration/Dialect/SparseTensor/taco/tools/mlir_pytaco.py

index 6f82016..18dccff 100644 (file)
@@ -353,7 +353,7 @@ class Format:
   def get_permutation_and_sparsity(self) -> Tuple[np.ndarray, np.ndarray]:
     """Constructs the numpy arrays for the permutation and sparsity."""
     perm = np.array(self.ordering.ordering, dtype=np.ulonglong)
-    a = [0 if s == ModeFormat.DENSE else 1 for s in self.format_pack.formats]
+    a = [f.value for f in self.format_pack.formats]
     sparse = np.array(a, dtype=np.uint8)
     return (perm, sparse)