@@ -248,6 +248,19 @@ def test_upsample(self): # type: () -> None
248248 [make_tensor_value_info ('y' , TensorProto .INT32 , (2 , 4 , 3 , 9 ))],
249249 opset_imports = [helper .make_opsetid ("" , 9 )])
250250
251+ def test_upsample_raw_data (self ): # type: () -> None
252+ graph = self ._make_graph (
253+ [('x' , TensorProto .INT32 , (2 , 4 , 3 , 5 )),
254+ ('scales' , TensorProto .FLOAT , (4 ,))],
255+ [make_node ("Upsample" , ['x' , 'scales' ], ['y' ])],
256+ [],
257+ initializer = [make_tensor ('scales' , TensorProto .FLOAT , (4 ,),
258+ vals = np .array ([1.0 , 1.1 , 1.3 , 1.9 ], dtype = '<f4' ).tobytes (), raw = True )]) # Feed raw bytes (force little endian ordering like onnx standard) for test purpose
259+ self ._assert_inferred (
260+ graph ,
261+ [make_tensor_value_info ('y' , TensorProto .INT32 , (2 , 4 , 3 , 9 ))],
262+ opset_imports = [helper .make_opsetid ("" , 9 )])
263+
251264 def test_resize (self ): # type: () -> None
252265 graph = self ._make_graph (
253266 [('x' , TensorProto .INT32 , (2 , 4 , 3 , 5 )),
@@ -786,6 +799,27 @@ def test_topk(self): # type: () -> None
786799 [make_tensor_value_info ('y' , TensorProto .FLOAT , (3 , 4 , 2 , 10 )),
787800 make_tensor_value_info ('z' , TensorProto .INT64 , (3 , 4 , 2 , 10 ))])
788801
802+ def test_topk_raw_data (self ): # type: () -> None
803+ graph = self ._make_graph (
804+ [('x' , TensorProto .FLOAT , (3 , 4 , 5 , 10 ))],
805+ [make_node ('TopK' , ['x' , 'k' ], ['y' , 'z' ], axis = 2 )],
806+ [],
807+ initializer = [make_tensor ('k' , TensorProto .INT64 , (1 ,),
808+ vals = np .array ([3 ], dtype = '<i8' ).tobytes (), raw = True )]) # Feed raw bytes (force little endian ordering like onnx standard) for test purpose
809+ self ._assert_inferred (graph ,
810+ [make_tensor_value_info ('y' , TensorProto .FLOAT , (3 , 4 , 3 , 10 )),
811+ make_tensor_value_info ('z' , TensorProto .INT64 , (3 , 4 , 3 , 10 ))])
812+
813+ def test_topk_missing_k_value_output_rank_check (self ): # type: () -> None
814+ graph = self ._make_graph (
815+ [('x' , TensorProto .FLOAT , (3 , 4 , 5 , 10 )),
816+ ('k' , TensorProto .INT64 , (1 ,))],
817+ [make_node ('TopK' , ['x' , 'k' ], ['y' , 'z' ], axis = 2 )],
818+ [])
819+ self ._assert_inferred (graph ,
820+ [make_tensor_value_info ('y' , TensorProto .FLOAT , (None , None , None , None )), # type: ignore
821+ make_tensor_value_info ('z' , TensorProto .INT64 , (None , None , None , None ))]) # type: ignore
822+
789823 def test_gemm (self ): # type: () -> None
790824 graph = self ._make_graph (
791825 [('x' , TensorProto .FLOAT , (7 , 5 )),
0 commit comments