PandA-2024.02
i4_tvm_compile.py
Go to the documentation of this file.
1 import numpy as np
2 import onnx
3 
4 from tvm import relay
5 import tvm
6 
7 onnx_model = onnx.load('i4_googlenet.onnx')
8 
9 input_name1 = '0'
10 input_shape1 = (1,3,224,224)
11 shape_dict = {input_name1: input_shape1}
12 
13 mod, params = relay.frontend.from_onnx(model=onnx_model, shape=shape_dict)
14 
15 
16 # Compilation
17 opt_level = 0
18 target = 'llvm'
19 with relay.build_config(opt_level=opt_level):
20  graph, lib, params = relay.build_module.build(
21  mod, target, params=params)
22 
23 
24 #printing some LLVM code
25 out_lib = open("i4_googlenet.ll", "w")
26 out_lib.write(lib.get_source())
27 out_lib.close()
28 out_graph = open("i4_googlenet.json", "w")
29 out_params = open("i4_googlenet.params", "w")
30 out_graph.write(graph)
31 out_graph.close()
32 print(params, file=out_params)
33 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