[Mlir-commits] [mlir] [MLIR] Graceful handling of unint sparse tensor encodings with `sparse-tensor-codegen` (PR #181145)
Aart Bik
llvmlistbot at llvm.org
Thu Feb 12 09:23:56 PST 2026
================
@@ -0,0 +1,20 @@
+// RUN: mlir-opt %s -sparse-tensor-codegen -verify-diagnostics
+
+#SparseVector = #sparse_tensor.encoding<{
+ map = (d0) -> (d0 : compressed)
+}>
+
+module {
+ func.func @main() -> tensor<8xf32, #SparseVector> {
+ %dense = arith.constant dense<[1.0, 0.0, 0.0, 2.0, 0.0, 3.0, 0.0, 0.0]>
+ : tensor<8xf32>
+
+ // expected-error at +1 {{failed to legalize operation 'sparse_tensor.convert' that was explicitly marked illegal}}
+ %sparse = sparse_tensor.convert %dense
----------------
aartbik wrote:
The construct is valid under the right passes. Even though you say that in the comment, it would be more clear if you have to RUN command for this file, one that lowers correct (--stage-sparse-ops --lower-sparse-ops-to-foreach or something like that) and one that generates this error when sparse codegen is called too soon
https://github.com/llvm/llvm-project/pull/181145
More information about the Mlir-commits
mailing list