|
1 | 1 | // RUN: mlir-opt %s -split-input-file -test-vector-linearize | FileCheck %s
|
| 2 | +// RUN: mlir-opt %s -split-input-file -test-vector-linearize=target-vector-bitwidth=128 | FileCheck %s --check-prefix=CHECK128 |
| 3 | +// RUN: mlir-opt %s -split-input-file -test-vector-linearize=target-vector-bitwidth=0 | FileCheck %s --check-prefix=CHECK0 |
2 | 4 |
|
3 | 5 | // CHECK-LABEL: test_linearize
|
| 6 | +// CHECK128-LABEL: test_linearize |
| 7 | +// CHECK0-LABEL: test_linearize |
4 | 8 | // CHECK-SAME: (%[[ORIG_ARG:.*]]: vector<2x2xf32>)
|
| 9 | +// CHECK128-SAME: (%[[ORIG_ARG:.*]]: vector<2x2xf32>) |
5 | 10 | // CHECK: %[[ARG:.*]] = vector.shape_cast %[[ORIG_ARG]] : vector<2x2xf32> to vector<4xf32>
|
| 11 | +// CHECK128: %[[ARG:.*]] = vector.shape_cast %[[ORIG_ARG]] : vector<2x2xf32> to vector<4xf32> |
6 | 12 | func.func @test_linearize(%arg0: vector<2x2xf32>) -> vector<2x2xf32> {
|
7 | 13 | // CHECK: %[[C1:.*]] = arith.constant dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32>
|
| 14 | +// CHECK128: %[[C1:.*]] = arith.constant dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32> |
| 15 | +// CHECK0: %[[C1:.*]] = arith.constant dense<{{.*}}> : vector<2x2xf32> |
| 16 | + |
8 | 17 | %0 = arith.constant dense<[[1.0, 2.0], [3.0, 4.0]]> : vector<2x2xf32>
|
9 | 18 | // CHECK: %[[RES:.*]] = vector.shape_cast %[[C1]] : vector<4xf32> to vector<2x2xf32>
|
10 |
| - |
| 19 | +// CHECK128: %[[RES:.*]] = vector.shape_cast %[[C1]] : vector<4xf32> to vector<2x2xf32> |
11 | 20 | // Arith and math ops are handled in generic way, check some of them
|
12 | 21 | // CHECK: %{{.*}} = math.sin %[[ARG]] : vector<4xf32>
|
| 22 | +// CHECK128: %{{.*}} = math.sin %[[ARG]] : vector<4xf32> |
| 23 | +// CHECK0: %{{.*}} = math.sin %{{.*}} : vector<2x2xf32> |
| 24 | + %1 = math.sin %arg0 : vector<2x2xf32> |
| 25 | +// CHECK: %{{.*}} = arith.addf %[[ARG]], %[[C1]] : vector<4xf32> |
| 26 | +// CHECK128: %{{.*}} = arith.addf %[[ARG]], %[[C1]] : vector<4xf32> |
| 27 | +// CHECK0: %{{.*}} = arith.addf %{{.*}} : vector<2x2xf32> |
| 28 | + |
| 29 | + %2 = arith.addf %arg0, %0 : vector<2x2xf32> |
| 30 | + |
| 31 | +// CHECK: return %[[RES]] : vector<2x2xf32> |
| 32 | +// CHECK128: return %[[RES]] : vector<2x2xf32> |
| 33 | + return %0 : vector<2x2xf32> |
| 34 | +} |
| 35 | + |
| 36 | +// CHECK-LABEL: test_partial_linearize |
| 37 | +// CHECK128-LABEL: test_partial_linearize |
| 38 | +// CHECK0-LABEL: test_partial_linearize |
| 39 | +// CHECK-SAME: (%[[ORIG_ARG:.*]]: vector<2x2xf32>, %[[ORIG_ARG2:.*]]: vector<4x4xf32>) |
| 40 | +// CHECK128-SAME: (%[[ORIG_ARG:.*]]: vector<2x2xf32>, %[[ORIG_ARG2:.*]]: vector<4x4xf32>) |
| 41 | +// CHECK0-SAME: (%[[ORIG_ARG:.*]]: vector<2x2xf32>, %[[ORIG_ARG2:.*]]: vector<4x4xf32>) |
| 42 | +// CHECK: %[[ARG:.*]] = vector.shape_cast %[[ORIG_ARG]] : vector<2x2xf32> to vector<4xf32> |
| 43 | +// CHECK128: %[[ARG:.*]] = vector.shape_cast %[[ORIG_ARG]] : vector<2x2xf32> to vector<4xf32> |
| 44 | +// CHECK: %[[ARG2:.*]] = vector.shape_cast %[[ORIG_ARG2]] : vector<4x4xf32> to vector<16xf32> |
| 45 | +func.func @test_partial_linearize(%arg0: vector<2x2xf32>, %arg1: vector<4x4xf32>) -> vector<2x2xf32> { |
| 46 | +// CHECK: %[[C1:.*]] = arith.constant dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32> |
| 47 | +// CHECK128: %[[C1:.*]] = arith.constant dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00]> : vector<4xf32> |
| 48 | +// CHECK0: %[[C1:.*]] = arith.constant dense<{{.*}}> : vector<2x2xf32> |
| 49 | + |
| 50 | + %0 = arith.constant dense<[[1.0, 2.0], [3.0, 4.0]]> : vector<2x2xf32> |
| 51 | +// CHECK: %[[RES:.*]] = vector.shape_cast %[[C1]] : vector<4xf32> to vector<2x2xf32> |
| 52 | +// CHECK128: %[[RES:.*]] = vector.shape_cast %[[C1]] : vector<4xf32> to vector<2x2xf32> |
| 53 | + |
| 54 | + // CHECK: %[[C2:.*]] = arith.constant dense<[1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00, 1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00, 1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00, 1.000000e+00, 2.000000e+00, 5.000000e+00, 6.000000e+00]> : vector<16xf32> |
| 55 | + // CHECK128: %[[C2:.*]] = arith.constant dense<{{.*}}> : vector<4x4xf32> |
| 56 | + // CHECK0: %[[C2:.*]] = arith.constant dense<{{.*}}> : vector<4x4xf32> |
| 57 | + %5 = arith.constant dense<[[1.0, 2.0, 3.0, 4.0], [1.0, 2.0,3.0, 4.0], [1.0, 2.0, 3.0, 4.0], [1.0, 2.0, 5.0, 6.0]]> : vector<4x4xf32> |
| 58 | +// Arith and math ops are handled in generic way, check some of them |
| 59 | +// CHECK: %[[SIN:.*]] = math.sin %[[ARG]] : vector<4xf32> |
| 60 | +// CHECK128: %[[SIN:.*]] = math.sin %[[ARG]] : vector<4xf32> |
| 61 | +// CHECK0: %[[SIN:.*]] = math.sin %[[ORIG_ARG]] : vector<2x2xf32> |
13 | 62 | %1 = math.sin %arg0 : vector<2x2xf32>
|
| 63 | + |
| 64 | + // CHECK: %[[SIN1:.*]] = math.sin %[[ARG2]] : vector<16xf32> |
| 65 | +// CHECK128: %[[SIN1:.*]] = math.sin %[[ORIG_ARG2]] : vector<4x4xf32> |
| 66 | +// CHECK0: %[[SIN1:.*]] = math.sin %[[ORIG_ARG2]] : vector<4x4xf32> |
| 67 | + %6 = math.sin %arg1 : vector<4x4xf32> |
14 | 68 | // CHECK: %{{.*}} = arith.addf %[[ARG]], %[[C1]] : vector<4xf32>
|
| 69 | +// CHECK128: %{{.*}} = arith.addf %[[ARG]], %[[C1]] : vector<4xf32> |
| 70 | +// CHECK0: %{{.*}} = arith.addf %{{.*}} : vector<2x2xf32> |
| 71 | + |
15 | 72 | %2 = arith.addf %arg0, %0 : vector<2x2xf32>
|
16 | 73 |
|
| 74 | + // CHECK: %[[ADD2:.*]] = arith.addf %[[ARG2]], %[[C2]] : vector<16xf32> |
| 75 | + // CHECK128: %[[ADD2:.*]] = arith.addf %[[ORIG_ARG2]], %[[C2]] : vector<4x4xf32> |
| 76 | + // CHECK0: %[[ADD2:.*]] = arith.addf %[[ORIG_ARG2]], %[[C2]] : vector<4x4xf32> |
| 77 | + %7 = arith.addf %arg1, %5 : vector<4x4xf32> |
17 | 78 | // CHECK: return %[[RES]] : vector<2x2xf32>
|
| 79 | +// CHECK128: return %[[RES]] : vector<2x2xf32> |
18 | 80 | return %0 : vector<2x2xf32>
|
19 | 81 | }
|
| 82 | + |
| 83 | +// CHECK-LABEL: test_index_no_linearize |
| 84 | +// CHECK128-LABEL: test_index_no_linearize |
| 85 | +// CHECK0-LABEL: test_index_no_linearize |
| 86 | +func.func @test_index_no_linearize(%arg0: vector<2x2xindex>, %arg1: vector<2x2xindex>) -> vector<2x2xindex> { |
| 87 | + // CHECK: %[[ADD:.*]] = arith.addi {{.*}} : vector<2x2xindex> |
| 88 | + // CHECK128: %[[ADD:.*]] = arith.addi {{.*}} : vector<2x2xindex> |
| 89 | + // CHECK0: %[[ADD:.*]] = arith.addi {{.*}} : vector<2x2xindex> |
| 90 | + %0 = arith.addi %arg0, %arg1 : vector<2x2xindex> |
| 91 | + return %0 : vector<2x2xindex> |
| 92 | +} |
0 commit comments