Skip to content

[mlir][sparse] update block24 example #70145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 25, 2023
Merged

[mlir][sparse] update block24 example #70145

merged 1 commit into from
Oct 25, 2023

Conversation

aartbik
Copy link
Contributor

@aartbik aartbik commented Oct 24, 2023

Removes TODO, shows how to define 8-bit crd (lacking 2-bit for now)

Removes TODO, shows how to define 8-bit crd (lacking 2-bit for now)
@llvmbot llvmbot added mlir:sparse Sparse compiler in MLIR mlir labels Oct 24, 2023
@llvmbot
Copy link
Member

llvmbot commented Oct 24, 2023

@llvm/pr-subscribers-mlir-sparse

@llvm/pr-subscribers-mlir

Author: Aart Bik (aartbik)

Changes

Removes TODO, shows how to define 8-bit crd (lacking 2-bit for now)


Full diff: https://github.com/llvm/llvm-project/pull/70145.diff

1 Files Affected:

  • (modified) mlir/test/Dialect/SparseTensor/roundtrip_encoding.mlir (+4-16)
diff --git a/mlir/test/Dialect/SparseTensor/roundtrip_encoding.mlir b/mlir/test/Dialect/SparseTensor/roundtrip_encoding.mlir
index ea8217ab6e3f233..db844312d02b999 100644
--- a/mlir/test/Dialect/SparseTensor/roundtrip_encoding.mlir
+++ b/mlir/test/Dialect/SparseTensor/roundtrip_encoding.mlir
@@ -130,19 +130,6 @@ func.func private @sparse_slice(tensor<?x?xf64, #CSR_SLICE>)
 
 // -----
 
-// TODO: It is probably better to use [dense, dense, 2:4] (see NV_24 defined using new syntax
-// below) to encode a 2D matrix, but it would require dim2lvl mapping which is not ready yet.
-// So we take the simple path for now.
-#NV_24= #sparse_tensor.encoding<{
-  map = (d0, d1) -> (d0 : dense, d1 : block2_4)
-}>
-
-// CHECK-LABEL: func private @sparse_2_out_of_4(
-// CHECK-SAME: tensor<?x?xf64, #sparse_tensor.encoding<{ map = (d0, d1) -> (d0 : dense, d1 : block2_4) }>>
-func.func private @sparse_2_out_of_4(tensor<?x?xf64, #NV_24>)
-
-// -----
-
 #BSR = #sparse_tensor.encoding<{
   map = ( i, j ) ->
   ( i floordiv 2 : dense,
@@ -204,11 +191,12 @@ func.func private @BSR_explicit(%arg0: tensor<?x?xf64, #BSR_explicit>) {
   ( i            : dense,
     j floordiv 4 : dense,
     j mod 4      : block2_4
-  )
+  ),
+  crdWidth = 8  // we would even like just 2-bits
 }>
 
 // CHECK-LABEL: func private @NV_24(
-// CHECK-SAME: tensor<?x?xf64, #sparse_tensor.encoding<{ map = (d0, d1) -> (d0 : dense, d1 floordiv 4 : dense, d1 mod 4 : block2_4) }>>
+// CHECK-SAME: tensor<?x?xf64, #sparse_tensor.encoding<{ map = (d0, d1) -> (d0 : dense, d1 floordiv 4 : dense, d1 mod 4 : block2_4), crdWidth = 8 }>>
 func.func private @NV_24(%arg0: tensor<?x?xf64, #NV_24>) {
   return
 }
@@ -245,4 +233,4 @@ func.func private @NV_24(%arg0: tensor<?x?x?xf64, #NV_24>) {
 // CHECK-SAME: tensor<?x?x?xf64, #sparse_tensor.encoding<{ map = (d0, d1, d2) -> (d0 : dense, d2 floordiv 4 : dense, d1 : dense, d2 mod 4 : block2_4) }>>
 func.func private @NV_24(%arg0: tensor<?x?x?xf64, #NV_24>) {
   return
-}
\ No newline at end of file
+}

@aartbik aartbik merged commit a12d057 into llvm:main Oct 25, 2023
@aartbik aartbik deleted the bik branch October 25, 2023 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mlir:sparse Sparse compiler in MLIR mlir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants