@@ -145,7 +145,7 @@ def test_transpose_with_split(self, input_shape, perm, inner_perm):
145
145
((1 , - 1 ), (1 , 1710 ), (1710 ,), [1 , 0 ]),
146
146
((3 , 1 , 1 , 5 , - 1 ), (3 , 1 , 1 , 5 , 6 ), (3 , 5 , 6 ), [0 , 2 , 3 , 4 , 1 ]),
147
147
])
148
- @check_opset_max_version (12 , "split attribute changed to input in opset 13" )
148
+ @check_opset_max_version (12 , "split attribute changed to input since opset 13" )
149
149
def test_transpose_with_split_dynamic_shape (self , input_shape , specific_input , output_shape , perm ):
150
150
node1 = helper .make_node ("Transpose" , ["X" ], ["Y" ], perm = perm , name = "trans" )
151
151
node2 = helper .make_node ("Split" , ["Y" ], ["Z" ], axis = 1 , split = [1 ], name = "split" )
@@ -162,6 +162,31 @@ def test_transpose_with_split_dynamic_shape(self, input_shape, specific_input, o
162
162
self .run_transpose_compare (["B" ], {"X" : np .random .randn (* specific_input ).astype (np .float32 )},
163
163
model_proto , remaining_transpose_num = 0 )
164
164
165
+ @parameterized .expand ([
166
+ ((3 , 1 , 1 ), (1 , 1 , 3 ), (1 ), [0 , 2 , 3 , 1 ]),
167
+ ((256 , 1 , 1 ), (1 , 1 , 256 ), (1 ), [0 , 2 , 3 , 1 ])
168
+ ])
169
+ @check_opset_min_version (13 , "split attribute changed to input since opset 13" )
170
+ def test_transpose_with_split_opset13 (self , input_shape , output_shape , split_val , perm ):
171
+ unsqueeze_axes = self ._make_onnx_const (np .array ([0 ], dtype = np .int64 ), "axes1" )
172
+ unsqueeze = helper .make_node ("Unsqueeze" , ["X" , "axes1" ], ["Y" ], name = "unsqueeze" )
173
+ trans = helper .make_node ("Transpose" , ["Y" ], ["Z" ], perm = perm , name = "trans" )
174
+ split_attr = self ._make_onnx_const (np .array ([split_val ], dtype = np .int64 ), "split_attr" )
175
+ split = helper .make_node ("Split" , ["Z" , "split_attr" ], ["A" ], axis = 0 , name = "split" )
176
+ squeeze_axes = self ._make_onnx_const (np .array ([1 ], dtype = np .int64 ), "axes2" )
177
+ squeeze = helper .make_node ("Squeeze" , ["A" , "axes2" ], ["B" ], name = "squeeze" )
178
+
179
+ graph = helper .make_graph (
180
+ [unsqueeze_axes , unsqueeze , trans , split_attr , split , squeeze_axes , squeeze ],
181
+ "test_transpose_with_split_opset13" ,
182
+ [helper .make_tensor_value_info ("X" , TensorProto .FLOAT , input_shape )],
183
+ [helper .make_tensor_value_info ("B" , TensorProto .FLOAT , output_shape )],
184
+ )
185
+
186
+ model_proto = self .make_model (graph , producer_name = "onnx-tests" )
187
+ self .run_transpose_compare (["B" ], {"X" : np .random .randn (* input_shape ).astype (np .float32 )},
188
+ model_proto , remaining_transpose_num = 0 )
189
+
165
190
@parameterized .expand ([
166
191
((2 , 3 , 4 ), [2 , 0 , 1 ], [1 , 2 , 0 ]),
167
192
((2 , 3 , 4 , 5 ), [0 , 2 , 3 , 1 ], [0 , 3 , 1 , 2 ]),
@@ -717,7 +742,7 @@ def test_transpose_sqrt(self, shape, perm_input, perm_output):
717
742
((1 , 3 , 4 , 5 ), (4 , 5 , 3 ), [0 , 2 , 3 , 1 ], [1 , 2 , 0 ]),
718
743
((1 , 3 , 4 , 5 , 6 ), (4 , 5 , 6 , 3 ), [0 , 2 , 3 , 4 , 1 ], [1 , 2 , 3 , 0 ]),
719
744
])
720
- @check_opset_max_version (12 , "Squeeze/Unsqueeze changed in opset 13" )
745
+ @check_opset_max_version (12 , "Squeeze/Unsqueeze changed since opset 13" )
721
746
def test_transpose_with_squeeze1 (self , input_shape , output_shape , perm , expected_perm ):
722
747
# squeeze the first dim
723
748
node1 = helper .make_node ("Transpose" , ["X" ], ["Y" ], perm = perm , name = "trans" )
@@ -768,7 +793,7 @@ def test_transpose_with_unsqueeze(self, input_shape, output_shape, perm, axes_va
768
793
((1 , 3 , 4 , 5 ), (4 , 5 , 3 ), [0 , 2 , 3 , 1 ], [1 , 2 , 0 ]),
769
794
((1 , 3 , 4 , 5 , 6 ), (4 , 5 , 6 , 3 ), [0 , 2 , 3 , 4 , 1 ], [1 , 2 , 3 , 0 ]),
770
795
])
771
- @check_opset_min_version (13 , "Squeeze/Unsqueeze changed in opset 13" )
796
+ @check_opset_min_version (13 , "Squeeze/Unsqueeze changed since opset 13" )
772
797
def test_transpose_with_squeeze1_13 (self , input_shape , output_shape , perm , expected_perm ):
773
798
# squeeze the first dim
774
799
node1 = helper .make_node ("Transpose" , ["X" ], ["Y" ], perm = perm , name = "trans" )
@@ -791,7 +816,7 @@ def test_transpose_with_squeeze1_13(self, input_shape, output_shape, perm, expec
791
816
((3 , 4 , 1 , 5 ), (3 , 5 , 4 ), [0 , 2 , 3 , 1 ], [0 , 2 , 1 ]),
792
817
((3 , 4 , 1 , 5 , 6 ), (3 , 5 , 6 , 4 ), [0 , 2 , 3 , 4 , 1 ], [0 , 2 , 3 , 1 ]),
793
818
])
794
- @check_opset_max_version (12 , "Squeeze/Unsqueeze changed in opset 13" )
819
+ @check_opset_max_version (12 , "Squeeze/Unsqueeze changed since opset 13" )
795
820
def test_transpose_with_squeeze2 (self , input_shape , output_shape , perm , expected_perm ):
796
821
# squeeze the second dim
797
822
node1 = helper .make_node ("Transpose" , ["X" ], ["Y" ], perm = perm , name = "trans" )
@@ -813,7 +838,7 @@ def test_transpose_with_squeeze2(self, input_shape, output_shape, perm, expected
813
838
((3 , 4 , 1 , 5 ), (3 , 5 , 4 ), [0 , 2 , 3 , 1 ], [0 , 2 , 1 ]),
814
839
((3 , 4 , 1 , 5 , 6 ), (3 , 5 , 6 , 4 ), [0 , 2 , 3 , 4 , 1 ], [0 , 2 , 3 , 1 ]),
815
840
])
816
- @check_opset_min_version (13 , "Squeeze/Unsqueeze changed in opset 13" )
841
+ @check_opset_min_version (13 , "Squeeze/Unsqueeze changed since opset 13" )
817
842
def test_transpose_with_squeeze2_13 (self , input_shape , output_shape , perm , expected_perm ):
818
843
# squeeze the second dim
819
844
node1 = helper .make_node ("Transpose" , ["X" ], ["Y" ], perm = perm , name = "trans" )
@@ -836,7 +861,7 @@ def test_transpose_with_squeeze2_13(self, input_shape, output_shape, perm, expec
836
861
((3 , 1 , 4 , 5 ), (3 , 4 , 5 ), [0 , 2 , 3 , 1 ]),
837
862
((3 , 1 , 4 , 5 , 6 ), (3 , 4 , 5 , 6 ), [0 , 2 , 3 , 4 , 1 ]),
838
863
])
839
- @check_opset_max_version (12 , "Squeeze/Unsqueeze changed in opset 13" )
864
+ @check_opset_max_version (12 , "Squeeze/Unsqueeze changed since opset 13" )
840
865
def test_transpose_with_squeeze3 (self , input_shape , output_shape , perm ):
841
866
# squeeze the last dim
842
867
node1 = helper .make_node ("Transpose" , ["X" ], ["Y" ], perm = perm , name = "trans" )
@@ -857,7 +882,7 @@ def test_transpose_with_squeeze3(self, input_shape, output_shape, perm):
857
882
((3 , 1 , 4 , 5 ), (3 , 4 , 5 ), [0 , 2 , 3 , 1 ]),
858
883
((3 , 1 , 4 , 5 , 6 ), (3 , 4 , 5 , 6 ), [0 , 2 , 3 , 4 , 1 ]),
859
884
])
860
- @check_opset_min_version (13 , "Squeeze/Unsqueeze changed in opset 13" )
885
+ @check_opset_min_version (13 , "Squeeze/Unsqueeze changed since opset 13" )
861
886
def test_transpose_with_squeeze3_13 (self , input_shape , output_shape , perm ):
862
887
# squeeze the last dim
863
888
node1 = helper .make_node ("Transpose" , ["X" ], ["Y" ], perm = perm , name = "trans" )
@@ -879,7 +904,7 @@ def test_transpose_with_squeeze3_13(self, input_shape, output_shape, perm):
879
904
((3 , 1 , 1 , 5 ), (3 , 5 ), [0 , 2 , 3 , 1 ]),
880
905
((3 , 1 , 1 , 5 , 4 ), (3 , 5 , 4 ), [0 , 2 , 3 , 4 , 1 ]),
881
906
])
882
- @check_opset_max_version (12 , "Squeeze/Unsqueeze changed in opset 13" )
907
+ @check_opset_max_version (12 , "Squeeze/Unsqueeze changed since opset 13" )
883
908
def test_transpose_with_squeeze4 (self , input_shape , output_shape , perm ):
884
909
# squeeze the two dims
885
910
node1 = helper .make_node ("Transpose" , ["X" ], ["Y" ], perm = perm , name = "trans" )
@@ -900,7 +925,7 @@ def test_transpose_with_squeeze4(self, input_shape, output_shape, perm):
900
925
((3 , 1 , 1 , 5 ), (3 , 5 ), [0 , 2 , 3 , 1 ]),
901
926
((3 , 1 , 1 , 5 , 4 ), (3 , 5 , 4 ), [0 , 2 , 3 , 4 , 1 ]),
902
927
])
903
- @check_opset_min_version (13 , "Squeeze/Unsqueeze changed in opset 13" )
928
+ @check_opset_min_version (13 , "Squeeze/Unsqueeze changed since opset 13" )
904
929
def test_transpose_with_squeeze4_13 (self , input_shape , output_shape , perm ):
905
930
# squeeze the two dims
906
931
node1 = helper .make_node ("Transpose" , ["X" ], ["Y" ], perm = perm , name = "trans" )
@@ -2156,7 +2181,7 @@ def test_const_fold_concat(self):
2156
2181
self .run_and_compare (["res" ], {"inp" : np .random .randn (6 , 12 ).astype (np .float32 )}, model_proto ,
2157
2182
"Concat" , 0 )
2158
2183
2159
- @check_opset_max_version (12 , "Squeeze/Unsqueeze changed in opset 13" )
2184
+ @check_opset_max_version (12 , "Squeeze/Unsqueeze changed since opset 13" )
2160
2185
def test_const_fold_unsqueeze_with_const (self ):
2161
2186
shape = (6 , 6 )
2162
2187
const_tensor = helper .make_tensor (name = 'const_tensor' , data_type = TensorProto .FLOAT , dims = shape ,
@@ -2176,7 +2201,7 @@ def test_const_fold_unsqueeze_with_const(self):
2176
2201
self .run_and_compare (["res" ], {"X" : np .random .randn (1 ).astype (np .float32 )}, model_proto ,
2177
2202
"Unsqueeze" , 0 )
2178
2203
2179
- @check_opset_min_version (13 , "Squeeze/Unsqueeze changed in opset 13" )
2204
+ @check_opset_min_version (13 , "Squeeze/Unsqueeze changed since opset 13" )
2180
2205
def test_const_fold_unsqueeze_with_const_13 (self ):
2181
2206
shape = (6 , 6 )
2182
2207
const_tensor = helper .make_tensor (name = 'const_tensor' , data_type = TensorProto .FLOAT , dims = shape ,
@@ -2254,7 +2279,7 @@ def test_const_fold_split_one(self):
2254
2279
self .run_and_compare (["out4" ], {"inp" : np .random .randn (2 , 6 , 1 ).astype (np .float32 )}, model_proto ,
2255
2280
"Split" , 0 )
2256
2281
2257
- @check_opset_min_version (13 , "Split changed in opset 13" )
2282
+ @check_opset_min_version (13 , "Split changed since opset 13" )
2258
2283
def test_const_fold_split_const_splits_13 (self ):
2259
2284
shape = (2 , 6 , 1 )
2260
2285
const_tensor = helper .make_tensor (name = 'const_tensor' , data_type = TensorProto .FLOAT , dims = shape ,
@@ -2277,7 +2302,7 @@ def test_const_fold_split_const_splits_13(self):
2277
2302
self .run_and_compare (["out4" ], {"inp" : np .random .randn (2 , 3 , 1 ).astype (np .float32 )}, model_proto ,
2278
2303
"Split" , 0 )
2279
2304
2280
- @check_opset_max_version (12 , "Split changed in opset 13" )
2305
+ @check_opset_max_version (12 , "Split changed since opset 13" )
2281
2306
def test_const_fold_split_const_splits (self ):
2282
2307
shape = (2 , 6 , 1 )
2283
2308
const_tensor = helper .make_tensor (name = 'const_tensor' , data_type = TensorProto .FLOAT , dims = shape ,
0 commit comments