|
| 1 | +// RUN: mlir-opt %s --lower-sparse-ops-to-foreach --split-input-file | FileCheck %s |
| 2 | + |
| 3 | +// Ensure that we exit gracefully rather than crashing. |
| 4 | + |
| 5 | +// CHECK-LABEL: func.func @test_tensor_dim_unranked |
| 6 | +// CHECK: tensor.dim |
| 7 | +func.func @test_tensor_dim_unranked(%arg0: tensor<*xf32>) -> index { |
| 8 | + %c = arith.constant 0 : index |
| 9 | + %0 = tensor.dim %arg0, %c : tensor<*xf32> |
| 10 | + return %0 : index |
| 11 | +} |
| 12 | + |
| 13 | +// ----- |
| 14 | + |
| 15 | +#SparseVector = #sparse_tensor.encoding<{ |
| 16 | + map = (d0) -> (d0 : compressed) |
| 17 | +}> |
| 18 | + |
| 19 | +// CHECK-LABEL: func.func @test_no_constant_dim |
| 20 | +// CHECK: tensor.dim |
| 21 | +func.func @test_no_constant_dim(%arg0: tensor<?xf64, #SparseVector>, %arg1: index) -> index { |
| 22 | + %0 = tensor.dim %arg0, %arg1 : tensor<?xf64, #SparseVector> |
| 23 | + return %0 : index |
| 24 | +} |
| 25 | + |
| 26 | +// ----- |
| 27 | + |
| 28 | +// CHECK-LABEL: func.func @test_tensor_dim_no_encoding |
| 29 | +// CHECK: tensor.dim |
| 30 | +func.func @test_tensor_dim_no_encoding(%arg0: tensor<?xf32>) -> index { |
| 31 | + %c = arith.constant 0 : index |
| 32 | + %0 = tensor.dim %arg0, %c : tensor<?xf32> |
| 33 | + return %0 : index |
| 34 | +} |
| 35 | + |
| 36 | +// ----- |
| 37 | + |
| 38 | +// CHECK-LABEL: func.func @test_tensor_reshape_unranked |
| 39 | +// CHECK: tensor.reshape |
| 40 | +func.func @test_tensor_reshape_unranked(%src: tensor<*xf32>, %shape: tensor<1xi32>) -> tensor<?xf32> { |
| 41 | + %dst = tensor.reshape %src(%shape) |
| 42 | + : (tensor<*xf32>, tensor<1xi32>) -> tensor<?xf32> |
| 43 | + return %dst : tensor<?xf32> |
| 44 | +} |
| 45 | + |
| 46 | +// ----- |
| 47 | + |
| 48 | +// CHECK-LABEL: func.func @test_tensor_reshape_no_encoding |
| 49 | +// CHECK: tensor.reshape |
| 50 | +func.func @test_tensor_reshape_no_encoding(%src: tensor<?x?xf32>, %shape: tensor<1xi32>) -> tensor<?xf32> { |
| 51 | + %dst = tensor.reshape %src(%shape) |
| 52 | + : (tensor<?x?xf32>, tensor<1xi32>) -> tensor<?xf32> |
| 53 | + return %dst : tensor<?xf32> |
| 54 | +} |
0 commit comments