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