From b543e775782e116b2344af3928e57f480d5a2aa7 Mon Sep 17 00:00:00 2001 From: rogday Date: Mon, 20 Dec 2021 19:54:07 +0300 Subject: [PATCH] add test data for Div --- testdata/dnn/onnx/data/input_div_const.npy | Bin 0 -> 144 bytes testdata/dnn/onnx/data/output_div_const.npy | Bin 0 -> 144 bytes testdata/dnn/onnx/generate_onnx_models.py | 26 ++++++++++++++++++++ testdata/dnn/onnx/models/div_const.onnx | Bin 0 -> 103 bytes 4 files changed, 26 insertions(+) create mode 100644 testdata/dnn/onnx/data/input_div_const.npy create mode 100644 testdata/dnn/onnx/data/output_div_const.npy create mode 100644 testdata/dnn/onnx/models/div_const.onnx 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 0000000000000000000000000000000000000000..ae1854526e18fa7a6a7afb893e2e7dc73fc99ed8 GIT binary patch literal 144 zcmbR27wQ`j$;eQ~P_3SlTAW;@Zl$1ZlV+l>qoAIaUsO_*m=~X4l#&V(cT3DEP6dh= dXCxM+0{I$7ItoUbItsN4WCJb+h6V>@3;-kl9%}#q literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..1e69cee394aad73da00b4f683d9221f004d37273 GIT binary patch literal 144 zcmbR27wQ`j$;eQ~P_3SlTAW;@Zl$1ZlV+l>qoAIaUsO_*m=~X4l#&V(cT3DEP6dh= dXCxM+0{I$7ItoUbItsN4WCJb+1_pa%3;+}39A^Lk literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..7b05613c51673e25b2d054336677cc7f9d5e828d GIT binary patch literal 103 zcmd