Skip to content

Commit 408842c

Browse files
committed
use simplest possible test and update comments
1 parent 9cf94bc commit 408842c

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

mlir/test/Dialect/Vector/canonicalize.mlir

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,25 +1028,26 @@ func.func @canonicalize_broadcast_shapecast_to_broadcast_scalar(%arg0: f32) -> v
10281028

10291029
// -----
10301030

1031-
// CHECK-LABEL: func @canonicalize_broadcast_shapecast_to_shapecast
1031+
// In this test, broadcast (2)->(1,2,1) is not legal, but shape_cast (2)->(1,2,1) is.
1032+
// CHECK-LABEL: func @canonicalize_broadcast_shapecast_to_shapcast
10321033
// CHECK-NOT: vector.broadcast
1033-
// CHECK: vector.shape_cast {{.+}} : vector<3x4xf32> to vector<1x12xf32>
1034-
func.func @canonicalize_broadcast_shapecast_to_shapecast(%arg0: vector<3x4xf32>) -> vector<1x12xf32> {
1035-
%0 = vector.broadcast %arg0 : vector<3x4xf32> to vector<1x1x3x4xf32>
1036-
%1 = vector.shape_cast %0 : vector<1x1x3x4xf32> to vector<1x12xf32>
1037-
return %1 : vector<1x12xf32>
1034+
// CHECK: vector.shape_cast {{.+}} : vector<2xf32> to vector<1x2x1xf32>
1035+
func.func @canonicalize_broadcast_shapecast_to_shapcast(%arg0 : vector<2xf32>) -> vector<1x2x1xf32> {
1036+
%0 = vector.broadcast %arg0 : vector<2xf32> to vector<1x2xf32>
1037+
%1 = vector.shape_cast %0 : vector<1x2xf32> to vector<1x2x1xf32>
1038+
return %1 : vector<1x2x1xf32>
10381039
}
10391040

10401041
// -----
10411042

1042-
// In this test, it could be folded to broadcast or shape_cast, shape_cast is chosen.
1043-
// CHECK-LABEL: func @canonicalize_broadcast_shapecast_to_shapcast_priority
1043+
// In this test, broadcast (1)->(1,1) and shape_cast (1)->(1,1) are both legal. shape_cast is chosen.
1044+
// CHECK-LABEL: func @canonicalize_broadcast_shapecast_both_possible
10441045
// CHECK-NOT: vector.broadcast
10451046
// CHECK: vector.shape_cast {{.+}} : vector<1xf32> to vector<1x1xf32>
1046-
func.func @canonicalize_broadcast_shapecast_to_shapcast_priority(%arg0 : vector<1xf32>) -> vector<1x1xf32> {
1047-
%0 = vector.broadcast %arg0 : vector<1xf32> to vector<1x1x1xf32>
1048-
%1 = vector.shape_cast %0 : vector<1x1x1xf32> to vector<1x1xf32>
1049-
return %1 : vector<1x1xf32>
1047+
func.func @canonicalize_broadcast_shapecast_both_possible(%arg0: vector<1xf32>) -> vector<1x1xf32> {
1048+
%0 = vector.broadcast %arg0 : vector<1xf32> to vector<1x1x1xf32>
1049+
%1 = vector.shape_cast %0 : vector<1x1x1xf32> to vector<1x1xf32>
1050+
return %1 : vector<1x1xf32>
10501051
}
10511052

10521053
// -----

0 commit comments

Comments
 (0)