@@ -1090,3 +1090,49 @@ func.func @torch.aten.mish$f8E8M0FNU(%arg0: !torch.vtensor<[2,3],f8E8M0FNU>) ->
10901090 %0 = torch.aten.mish %arg0 : !torch.vtensor <[2 ,3 ],f8E8M0FNU > -> !torch.vtensor <[2 ,3 ],f8E8M0FNU >
10911091 return %0 : !torch.vtensor <[2 ,3 ],f8E8M0FNU >
10921092}
1093+
1094+ // -----
1095+
1096+ // CHECK-LABEL: func.func @repeat_mixed_dims_broadcast_singletons
1097+ // CHECK-SAME: (%[[ARG0:.*]]: !torch.vtensor<[1,2,1],f32>) -> !torch.vtensor<[3,8,5],f32>
1098+ // CHECK-DAG: %[[CNEG1:.*]] = torch.constant.int -1
1099+ // CHECK-DAG: %[[C1:.*]] = torch.constant.int 1
1100+ // CHECK-DAG: %[[C2:.*]] = torch.constant.int 2
1101+ // CHECK-DAG: %[[C3:.*]] = torch.constant.int 3
1102+ // CHECK-DAG: %[[C4:.*]] = torch.constant.int 4
1103+ // CHECK-DAG: %[[C5:.*]] = torch.constant.int 5
1104+ // CHECK: %[[UNSQUEEZE:.*]] = torch.aten.unsqueeze %[[ARG0]], %[[C1]] : !torch.vtensor<[1,2,1],f32>, !torch.int -> !torch.vtensor<[1,1,2,1],f32>
1105+ // CHECK: %[[SHAPE:.*]] = torch.prim.ListConstruct %[[C3]], %[[C4]], %[[C2]], %[[C5]] : (!torch.int, !torch.int, !torch.int, !torch.int) -> !torch.list<int>
1106+ // CHECK: %[[BROADCAST:.*]] = torch.aten.broadcast_to %[[UNSQUEEZE]], %[[SHAPE]] : !torch.vtensor<[1,1,2,1],f32>, !torch.list<int> -> !torch.vtensor<[3,4,2,5],f32>
1107+ // CHECK: %[[VIEW_SHAPE:.*]] = torch.prim.ListConstruct %[[C3]], %[[CNEG1]], %[[C5]] : (!torch.int, !torch.int, !torch.int) -> !torch.list<int>
1108+ // CHECK: %[[VIEW:.*]] = torch.aten.view %[[BROADCAST]], %[[VIEW_SHAPE]] : !torch.vtensor<[3,4,2,5],f32>, !torch.list<int> -> !torch.vtensor<[3,8,5],f32>
1109+ // CHECK: return %[[VIEW]] : !torch.vtensor<[3,8,5],f32>
1110+ func.func @repeat_mixed_dims_broadcast_singletons (%arg0: !torch.vtensor <[1 ,2 ,1 ],f32 >) -> !torch.vtensor <[3 ,8 ,5 ],f32 > {
1111+ %int3 = torch.constant.int 3
1112+ %int4 = torch.constant.int 4
1113+ %int5 = torch.constant.int 5
1114+ %0 = torch.prim.ListConstruct %int3 , %int4 , %int5 : (!torch.int , !torch.int , !torch.int ) -> !torch.list <int >
1115+ %1 = torch.aten.repeat %arg0 , %0 : !torch.vtensor <[1 ,2 ,1 ],f32 >, !torch.list <int > -> !torch.vtensor <[3 ,8 ,5 ],f32 >
1116+ return %1 : !torch.vtensor <[3 ,8 ,5 ],f32 >
1117+ }
1118+
1119+ // -----
1120+
1121+ // CHECK-LABEL: func @repeat_broadcasts_static_singleton_dims
1122+ func.func @repeat_broadcasts_static_singleton_dims (%arg0: !torch.vtensor <[1 ,1 ,6 ,1 ,4 ,4 ],f32 >) -> !torch.vtensor <[4 ,1 ,6 ,2500 ,4 ,4 ],f32 > {
1123+ %int4 = torch.constant.int 4
1124+ %int1 = torch.constant.int 1
1125+ %int2500 = torch.constant.int 2500
1126+ // CHECK-DAG: %[[C4:.*]] = torch.constant.int 4
1127+ // CHECK-DAG: %[[C2500:.*]] = torch.constant.int 2500
1128+ // CHECK-DAG: %[[C1:.*]] = torch.constant.int 1
1129+ // CHECK-DAG: %[[C6:.*]] = torch.constant.int 6
1130+ // CHECK: %[[SHAPE:.*]] = torch.prim.ListConstruct %[[C4]], %[[C1]], %[[C6]], %[[C2500]], %[[C4]], %[[C4]] : (!torch.int, !torch.int, !torch.int, !torch.int, !torch.int, !torch.int) -> !torch.list<int>
1131+ // CHECK-NOT: torch.aten.unsqueeze
1132+ // CHECK-NOT: torch.aten.flatten
1133+ // CHECK: %[[BROADCAST:.*]] = torch.aten.broadcast_to %arg0, %[[SHAPE]] : !torch.vtensor<[1,1,6,1,4,4],f32>, !torch.list<int> -> !torch.vtensor<[4,1,6,2500,4,4],f32>
1134+ // CHECK: return %[[BROADCAST]] : !torch.vtensor<[4,1,6,2500,4,4],f32>
1135+ %repeats = torch.prim.ListConstruct %int4 , %int1 , %int1 , %int2500 , %int1 , %int1 : (!torch.int , !torch.int , !torch.int , !torch.int , !torch.int , !torch.int ) -> !torch.list <int >
1136+ %0 = torch.aten.repeat %arg0 , %repeats : !torch.vtensor <[1 ,1 ,6 ,1 ,4 ,4 ],f32 >, !torch.list <int > -> !torch.vtensor <[4 ,1 ,6 ,2500 ,4 ,4 ],f32 >
1137+ return %0 : !torch.vtensor <[4 ,1 ,6 ,2500 ,4 ,4 ],f32 >
1138+ }
0 commit comments