llvm-project/mlir/test/Dialect/SparseTensor/one_shot_bufferize_invalid.mlir
Matthias Springer 79ff70fda2 [mlir][sparse] Better error handling when bufferizing sparse_tensor ops
sparse_tensor ops cannot be bufferized with One-Shot Bufferize. (They can only be analyzed.) The sparse compiler does the actual lowering to memref. Produce a proper error message instead of crashing.

This fixes #61311.

Differential Revision: https://reviews.llvm.org/D158728
2023-08-25 08:34:05 +02:00

13 lines
527 B
MLIR

// RUN: mlir-opt %s -one-shot-bufferize -verify-diagnostics
#SparseVector = #sparse_tensor.encoding<{
lvlTypes = ["compressed"]
}>
func.func @sparse_tensor_op(%arg0: tensor<64xf32, #SparseVector>) -> tensor<64xf32, #SparseVector> {
// expected-error @below{{sparse_tensor ops must be bufferized with the sparse compiler}}
// expected-error @below{{failed to bufferize op}}
%0 = sparse_tensor.convert %arg0 : tensor<64xf32, #SparseVector> to tensor<64xf32, #SparseVector>
return %0 : tensor<64xf32, #SparseVector>
}