@@ -1821,3 +1821,29 @@ def forward(self, x):
18211821model = ArgMin ()
18221822input_ = Variable (torch .randn (2 , 3 , 4 , 5 , dtype = torch .float32 ))
18231823save_data_and_model ("argmin" , input_ , model )
1824+
1825+ ########################## const / x ##########################
1826+
1827+ node = onnx .helper .make_node ('Div' , inputs = ['x' , 'y' ], outputs = ['z' ])
1828+
1829+ x = np .array ([2 ]).astype (np .float32 )
1830+ y = np .array ([[4 , 4 ], [4 , 4 ]]).astype (np .float32 )
1831+ name = 'div_const'
1832+ input_files = os .path .join ("data" , "input_" + name )
1833+ np .save (input_files , x .data )
1834+ np .save (input_files , y .data )
1835+
1836+ z = (x / y ).astype (np .float32 )
1837+ output_files = os .path .join ("data" , "output_" + name )
1838+ np .save (output_files , np .ascontiguousarray (z .data ))
1839+
1840+ X = onnx .helper .make_tensor ('x' , onnx .TensorProto .FLOAT , x .shape , x )
1841+ Y = onnx .helper .make_tensor_value_info ('y' , onnx .TensorProto .FLOAT , y .shape )
1842+ Z = onnx .helper .make_tensor_value_info ('z' , onnx .TensorProto .FLOAT , z .shape )
1843+
1844+ graph = onnx .helper .make_graph ([node ], 'div_const' , [Y ], [Z ], initializer = [X ])
1845+ model = onnx .helper .make_model (graph , producer_name = name )
1846+ models_files = os .path .join ("models" , name + ".onnx" )
1847+ onnx .save (model , models_files )
1848+
1849+ ########################## const / x ##########################
0 commit comments