Skip to content

Commit 22453c9

Browse files
author
Yang Bai
committed
add test
1 parent 7586aa1 commit 22453c9

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

mlir/test/Dialect/Vector/constant-fold.mlir

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,29 @@ func.func @fold_extract_transpose_negative(%arg0: vector<4x4xf16>) -> vector<4x4
1111
%2 = vector.extract %1[0] : vector<4x4xf16> from vector<1x4x4xf16>
1212
return %2 : vector<4x4xf16>
1313
}
14+
15+
// -----
16+
17+
// CHECK-LABEL: fold_extract_in_single_pass
18+
// CHECK-SAME: (%{{.*}}: vector<4xf16>, %[[ARG1:.+]]: f16)
19+
func.func @fold_extract_in_single_pass(%arg0: vector<4xf16>, %arg1: f16) -> f16 {
20+
%0 = vector.insert %arg1, %arg0 [1] : f16 into vector<4xf16>
21+
%c1 = arith.constant 1 : index
22+
// Verify that the fold is finished in a single pass even if the index is dynamic.
23+
%1 = vector.extract %0[%c1] : f16 from vector<4xf16>
24+
// CHECK: return %[[ARG1]] : f16
25+
return %1 : f16
26+
}
27+
28+
// -----
29+
30+
// CHECK-LABEL: fold_insert_in_single_pass
31+
func.func @fold_insert_in_single_pass() -> vector<2xf16> {
32+
%cst = arith.constant dense<0.000000e+00> : vector<2xf16>
33+
%c1 = arith.constant 1 : index
34+
%c2 = arith.constant 2.5 : f16
35+
// Verify that the fold is finished in a single pass even if the index is dynamic.
36+
// CHECK: arith.constant dense<[0.000000e+00, 2.500000e+00]> : vector<2xf16>
37+
%0 = vector.insert %c2, %cst [%c1] : f16 into vector<2xf16>
38+
return %0 : vector<2xf16>
39+
}

0 commit comments

Comments
 (0)