PandA-2024.02
12_onnx_build.py
Go to the documentation of this file.
1 import numpy as np
2 
3 import onnx
4 from onnx import helper, shape_inference, optimizer
5 from onnx import numpy_helper
6 from onnx import AttributeProto, TensorProto, GraphProto
7 
8 # Create graph input X
9 X = helper.make_tensor_value_info('X', TensorProto.FLOAT, [1, 1, 8, 8])
10 
11 # Create graph output Y
12 Y = helper.make_tensor_value_info('Y', TensorProto.FLOAT, [1, 1, 2, 2])
13 
14 maxp1 = helper.make_node(
15  'MaxPool', # name
16  ['X'], # inputs
17  ['Y'], # outputs
18 
19  auto_pad = 'VALID',
20  kernel_shape=[3, 3],
21  strides=[3, 3],
22  )
23 
24 
25 graph_def = helper.make_graph(
26  nodes=[maxp1], # graph nodes
27  name= 'maxp_a_model', # graph name
28  inputs = [X], # graph inputs
29  outputs = [Y], # graph outputs
30  )
31 
32 model_def = helper.make_model(graph_def, producer_name='benchmarks')
33 
34 onnx.checker.check_model(model_def)
35 model_def = shape_inference.infer_shapes(model_def)
36 onnx.checker.check_model(model_def)
37 model_def = optimizer.optimize(model_def)
38 onnx.checker.check_model(model_def)
39 
40 onnx.save_model(model_def, '12_maxp_a.onnx')

Generated on Mon Feb 12 2024 13:02:50 for PandA-2024.02 by doxygen 1.8.13