PandA-2024.02
lenet_tvm.py
Go to the documentation of this file.
1 import onnx
2 
3 from tvm import relay
4 import tvm
5 import os
6 
7 onnx_model = onnx.load('lenet.onnx')
8 
9 input_name = 'import/Placeholder:0'
10 input_shape = (1,1,28,28)
11 shape_dict = {input_name: input_shape}
12 
13 mod, params = relay.frontend.from_onnx(model=onnx_model, shape=shape_dict)
14 
15 opt_level=0
16 target = 'llvm'
17 with relay.build_config(opt_level=opt_level):
18  graph, lib, params = relay.build_module.build(mod, target, params=params)
19 
20 
21 out_lib = open("lenet.ll", "w")
22 out_graph = open("lenet.json", "w")
23 out_params = open("lenet.params", "w")
24 out_lib.write(lib.get_source())
25 out_lib.close()
26 out_graph.write(graph)
27 out_graph.close()
28 print(params, file=out_params)
29 out_params.close()
void print(int x)

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