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

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