llvm-project
fd3c3024 - [mlir][sparse] Load the vector dialect in pre-sparsification-rewrite (#216491)

Commit
74 days ago
[mlir][sparse] Load the vector dialect in pre-sparsification-rewrite (#216491) Fixes #216273 `mlir-opt --pre-sparsification-rewrite` aborts on this input: ```mlir #sparse = #sparse_tensor.encoding<{ map = (d0, d1) -> (d0 : dense, d1 : compressed) }> func.func @print(%arg0: !llvm.ptr) { %0 = sparse_tensor.new %arg0 : !llvm.ptr to tensor<?x?xf32, #sparse> sparse_tensor.print %0 : tensor<?x?xf32, #sparse> llvm.return } ``` ``` LLVM ERROR: can't create Attribute 'mlir::vector::PrintPunctuationAttr' because storage uniquer isn't initialized: the dialect was likely not loaded, ... ``` `PrintRewriter` lowers `sparse_tensor.print` into `vector.print` operations, but `PreSparsificationRewrite` does not list the vector dialect in `dependentDialects`. When the input does not use the dialect either, it is never loaded and building the punctuation attribute aborts. The pass already declares the other dialects it needs, so this just adds the missing one. Testing: added a `sparse_tensor.print` case to `mlir/test/Dialect/SparseTensor/pre_rewriting.mlir`, which does not otherwise mention the vector dialect. The test fails on main and passes with the change, and `mlir/test/Dialect/SparseTensor` stays at 113/113.
Author
Parents
Loading