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