Skip to content

Commit 5a8a68e

Browse files
committed
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
2 parents 5002d3d + b2e7c8a commit 5a8a68e

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed
144 Bytes
Binary file not shown.
144 Bytes
Binary file not shown.

testdata/dnn/onnx/generate_onnx_models.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,3 +1821,29 @@ def forward(self, x):
18211821
model = ArgMin()
18221822
input_ = Variable(torch.randn(2, 3, 4, 5, dtype=torch.float32))
18231823
save_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 ##########################
103 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)