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

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