@@ -1558,3 +1558,29 @@ def forward(self, x):
15581558model = SubFromConst1 ()
15591559input_ = Variable (torch .randn (1 , 2 , 3 , 4 , dtype = torch .float32 ))
15601560save_data_and_model ("sub_from_const1" , input_ , model )
1561+
1562+ ########################## const / x ##########################
1563+
1564+ node = onnx .helper .make_node ('Div' , inputs = ['x' , 'y' ], outputs = ['z' ])
1565+
1566+ x = np .array ([2 ]).astype (np .float32 )
1567+ y = np .array ([[4 , 4 ], [4 , 4 ]]).astype (np .float32 )
1568+ name = 'div_const'
1569+ input_files = os .path .join ("data" , "input_" + name )
1570+ np .save (input_files , x .data )
1571+ np .save (input_files , y .data )
1572+
1573+ z = (x / y ).astype (np .float32 )
1574+ output_files = os .path .join ("data" , "output_" + name )
1575+ np .save (output_files , np .ascontiguousarray (z .data ))
1576+
1577+ X = onnx .helper .make_tensor ('x' , onnx .TensorProto .FLOAT , x .shape , x )
1578+ Y = onnx .helper .make_tensor_value_info ('y' , onnx .TensorProto .FLOAT , y .shape )
1579+ Z = onnx .helper .make_tensor_value_info ('z' , onnx .TensorProto .FLOAT , z .shape )
1580+
1581+ graph = onnx .helper .make_graph ([node ], 'div_const' , [Y ], [Z ], initializer = [X ])
1582+ model = onnx .helper .make_model (graph , producer_name = name )
1583+ models_files = os .path .join ("models" , name + ".onnx" )
1584+ onnx .save (model , models_files )
1585+
1586+ ########################## const / x ##########################
0 commit comments