PandA-2024.02
07_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,64])
10 
11 
12 # Create graph output Y
13 Z = helper.make_tensor_value_info('Z', TensorProto.FLOAT, [1,64])
14 
15 smax1 = helper.make_node(
16  'Softmax', # name
17  ['X'], # inputs
18  ['Z'], # outputs
19  )
20 
21 graph_def = helper.make_graph(
22  nodes=[smax1], # graph nodes
23  name= 'softmax_b_model', # graph name
24  inputs = [X], # graph inputs
25  outputs = [Z], # graph outputs
26  )
27 
28 model_def = helper.make_model(graph_def, producer_name='benchmarks')
29 
30 onnx.checker.check_model(model_def)
31 model_def = shape_inference.infer_shapes(model_def)
32 onnx.checker.check_model(model_def)
33 model_def = optimizer.optimize(model_def)
34 onnx.checker.check_model(model_def)
35 
36 onnx.save_model(model_def, '07_softmax_b.onnx')

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