diff --git a/mlir/test/Dialect/SparseTensor/codegen.mlir b/mlir/test/Dialect/SparseTensor/codegen.mlir index df03d871ba3a3..af78458f10932 100644 --- a/mlir/test/Dialect/SparseTensor/codegen.mlir +++ b/mlir/test/Dialect/SparseTensor/codegen.mlir @@ -826,19 +826,3 @@ func.func @sparse_new_coo_permute_no(%arg0: !llvm.ptr) -> tensor return %0 : tensor } - -// CHECK-LABEL: func.func @test_tensor_dim_unranked -// CHECK: tensor.dim -func.func @test_tensor_dim_unranked(%arg0: tensor<*xf32>) -> index { - %c = arith.constant 0 : index - %0 = tensor.dim %arg0, %c : tensor<*xf32> - return %0 : index -} - -// CHECK-LABEL: func.func @test_tensor_reshape_unranked -// CHECK: tensor.reshape -func.func @test_tensor_reshape_unranked(%src: tensor<*xf32>, %shape: tensor<1xi32>) -> tensor { - %dst = tensor.reshape %src(%shape) - : (tensor<*xf32>, tensor<1xi32>) -> tensor - return %dst : tensor -} diff --git a/mlir/test/Dialect/SparseTensor/no_lowering.mlir b/mlir/test/Dialect/SparseTensor/no_lowering.mlir new file mode 100644 index 0000000000000..4f21055a13d58 --- /dev/null +++ b/mlir/test/Dialect/SparseTensor/no_lowering.mlir @@ -0,0 +1,54 @@ +// RUN: mlir-opt %s --lower-sparse-ops-to-foreach --split-input-file | FileCheck %s + +// Ensure that we exit gracefully rather than crashing. + +// CHECK-LABEL: func.func @test_tensor_dim_unranked +// CHECK: tensor.dim +func.func @test_tensor_dim_unranked(%arg0: tensor<*xf32>) -> index { + %c = arith.constant 0 : index + %0 = tensor.dim %arg0, %c : tensor<*xf32> + return %0 : index +} + +// ----- + +#SparseVector = #sparse_tensor.encoding<{ + map = (d0) -> (d0 : compressed) +}> + +// CHECK-LABEL: func.func @test_no_constant_dim +// CHECK: tensor.dim +func.func @test_no_constant_dim(%arg0: tensor, %arg1: index) -> index { + %0 = tensor.dim %arg0, %arg1 : tensor + return %0 : index +} + +// ----- + +// CHECK-LABEL: func.func @test_tensor_dim_no_encoding +// CHECK: tensor.dim +func.func @test_tensor_dim_no_encoding(%arg0: tensor) -> index { + %c = arith.constant 0 : index + %0 = tensor.dim %arg0, %c : tensor + return %0 : index +} + +// ----- + +// CHECK-LABEL: func.func @test_tensor_reshape_unranked +// CHECK: tensor.reshape +func.func @test_tensor_reshape_unranked(%src: tensor<*xf32>, %shape: tensor<1xi32>) -> tensor { + %dst = tensor.reshape %src(%shape) + : (tensor<*xf32>, tensor<1xi32>) -> tensor + return %dst : tensor +} + +// ----- + +// CHECK-LABEL: func.func @test_tensor_reshape_no_encoding +// CHECK: tensor.reshape +func.func @test_tensor_reshape_no_encoding(%src: tensor, %shape: tensor<1xi32>) -> tensor { + %dst = tensor.reshape %src(%shape) + : (tensor, tensor<1xi32>) -> tensor + return %dst : tensor +}