I used tvm to translate a resnet18 I built in Python into C language. However, the generated C language code is extremely complicated, and there seems to be no top-level interface. How should I use the generated C code?
complicated as it is indeed, it’s ok if we can build it with no error(warnings could be accepted!)
try surrounding your relay.build
with
with tvm.transform.PassContext(opt_level=3, config={"tir.disable_vectorize": True}):
relay.build(...)
TVM codegen only works for operators but not the entire graph. So it’s impossible to run the e2e model via c code. (I am not sure if AOT helps, not familiar with it)
TVM uses a runtime to execute the model if you compile it via relay or relax
Thank you sir, I successfully compiled it!
Got you bro. But what I want to do is, can I convert the model in Python into a model in C and run it correctly under C?This is a project my teacher asked me to do, and I know very little about compilers,so I just try to do in this way. Does this “for operators” mean to use lamba expressions to translate operators not the whole model?
生成的op的C代码,需要用relay(or relax)编译,并加载到虚拟机里执行,如果你用的是异构设备,还涉及到Host端代码。总之,即使你想跑一下很简单的z=x + y,你无法脱离这个编译-推理架构,我理解你应该是想生成纯C代码,使用GCC编译,生成可执行文件(gcc -o a.out xxx.cc, and ./a.out)
能加个vx吗大哥 有点问题想请教一下您