|
1 |
| -// RUN: mlir-opt -split-input-file -convert-tensor-to-spirv -verify-diagnostics %s | FileCheck %s |
| 1 | +// RUN: mlir-opt --split-input-file --convert-tensor-to-spirv \ |
| 2 | +// RUN: --verify-diagnostics %s | FileCheck %s |
2 | 3 |
|
3 | 4 | //===----------------------------------------------------------------------===//
|
4 | 5 | // tensor.extract
|
@@ -27,3 +28,38 @@ func.func @tensor_extract_constant(%a : index, %b: index, %c: index) -> i32 {
|
27 | 28 | // CHECK: spirv.ReturnValue %[[VAL]]
|
28 | 29 | return %extract : i32
|
29 | 30 | }
|
| 31 | + |
| 32 | +// ----- |
| 33 | + |
| 34 | +//===----------------------------------------------------------------------===// |
| 35 | +// Type conversion |
| 36 | +//===----------------------------------------------------------------------===// |
| 37 | + |
| 38 | +// CHECK-LABEL: func @tensor_0d |
| 39 | +// CHECK-NEXT: spirv.Constant 1 : i32 |
| 40 | +func.func @tensor_0d() -> () { |
| 41 | + %x = arith.constant dense<1> : tensor<i32> |
| 42 | + return |
| 43 | +} |
| 44 | + |
| 45 | +// CHECK-LABEL: func @tensor_1d |
| 46 | +// CHECK-NEXT: spirv.Constant dense<[1, 2, 3]> : tensor<3xi32> : !spirv.array<3 x i32> |
| 47 | +func.func @tensor_1d() -> () { |
| 48 | + %x = arith.constant dense<[1, 2, 3]> : tensor<3xi32> |
| 49 | + return |
| 50 | +} |
| 51 | + |
| 52 | +// CHECK-LABEL: func @tensor_2d |
| 53 | +// CHECK-NEXT: spirv.Constant dense<[1, 2, 3, 4, 5, 6]> : tensor<6xi32> : !spirv.array<6 x i32> |
| 54 | +func.func @tensor_2d() -> () { |
| 55 | + %x = arith.constant dense<[[1, 2, 3], [4, 5, 6]]> : tensor<2x3xi32> |
| 56 | + return |
| 57 | +} |
| 58 | + |
| 59 | +// We do not handle zero-element tensors yet. Just make we do not crash on them. |
| 60 | +// CHECK-LABEL: func @tensor_2d_empty |
| 61 | +// CHECK-NEXT: arith.constant dense<> |
| 62 | +func.func @tensor_2d_empty() -> () { |
| 63 | + %x = arith.constant dense<> : tensor<2x0xi32> |
| 64 | + return |
| 65 | +} |
0 commit comments