diff --git a/testdata/dnn/onnx/data/input_div_const.npy b/testdata/dnn/onnx/data/input_div_const.npy new file mode 100644 index 000000000..ae1854526 Binary files /dev/null and b/testdata/dnn/onnx/data/input_div_const.npy differ diff --git a/testdata/dnn/onnx/data/output_div_const.npy b/testdata/dnn/onnx/data/output_div_const.npy new file mode 100644 index 000000000..1e69cee39 Binary files /dev/null and b/testdata/dnn/onnx/data/output_div_const.npy differ diff --git a/testdata/dnn/onnx/generate_onnx_models.py b/testdata/dnn/onnx/generate_onnx_models.py index d1965c2f4..b930c84d2 100644 --- a/testdata/dnn/onnx/generate_onnx_models.py +++ b/testdata/dnn/onnx/generate_onnx_models.py @@ -1558,3 +1558,29 @@ def forward(self, x): model = SubFromConst1() input_ = Variable(torch.randn(1, 2, 3, 4, dtype=torch.float32)) save_data_and_model("sub_from_const1", input_, model) + +########################## const / x ########################## + +node = onnx.helper.make_node('Div', inputs=['x', 'y'], outputs=['z']) + +x = np.array([2]).astype(np.float32) +y = np.array([[4, 4], [4, 4]]).astype(np.float32) +name = 'div_const' +input_files = os.path.join("data", "input_" + name) +np.save(input_files, x.data) +np.save(input_files, y.data) + +z = (x / y).astype(np.float32) +output_files = os.path.join("data", "output_" + name) +np.save(output_files, np.ascontiguousarray(z.data)) + +X = onnx.helper.make_tensor('x', onnx.TensorProto.FLOAT, x.shape, x) +Y = onnx.helper.make_tensor_value_info('y', onnx.TensorProto.FLOAT, y.shape) +Z = onnx.helper.make_tensor_value_info('z', onnx.TensorProto.FLOAT, z.shape) + +graph = onnx.helper.make_graph([node], 'div_const', [Y], [Z], initializer=[X]) +model = onnx.helper.make_model(graph, producer_name=name) +models_files = os.path.join("models", name + ".onnx") +onnx.save(model, models_files) + +########################## const / x ########################## diff --git a/testdata/dnn/onnx/models/div_const.onnx b/testdata/dnn/onnx/models/div_const.onnx new file mode 100644 index 000000000..7b05613c5 Binary files /dev/null and b/testdata/dnn/onnx/models/div_const.onnx differ