Skip to content

Commit b543e77

Browse files
committed
add test data for Div
1 parent 01e8a30 commit b543e77

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
@@ -1558,3 +1558,29 @@ def forward(self, x):
15581558
model = SubFromConst1()
15591559
input_ = Variable(torch.randn(1, 2, 3, 4, dtype=torch.float32))
15601560
save_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 ##########################
103 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)