Hello, I am new to TVM so maybe this is an easy question.
I have a PyTorch model which I converted into TVM using tvm.relay.frontend.from_pytorch. I generated A library using the following:
tvm_target = tvm.target.Target(f"{target} -libs=math")
with tvm.transform.PassContext(opt_level=3):
lib = relay.build(
mod,
target=tvm_target,
params=params,
runtime=relay.backend.Runtime("crt"),
executor=relay.backend.Executor("aot", {
"unpacked-api": True,
"link-params": True
}),
mod_name=model_name
)
From here, I want to build my model into a standalone static library which I can then link to my embedded C application (I want to try GCC and then my final goal would be to build it for a SPARC platform). My code as of now is the following:
# 4. Export the compiled artifacts
os.makedirs(output_dir, exist_ok=True)
lib.get_lib().save(os.path.join(output_dir, f"{model_name}.c"))
lib.export_library(os.path.join(output_dir, f"{model_name}.tar"))
print(f"✅ Built and saved TVM model in '{output_dir}'")
# temp_dir = utils.tempdir(os.path.join(output_dir,f'build_{model_name}'))
# path_c = temp_dir.relpath(f"{model_name}.c")
os.makedirs(os.path.join(output_dir,f'build_{model_name}'), exist_ok=True)
# Compile
cc.create_shared(
os.path.join(output_dir,f'build_{model_name}',"libgcc_model.a"),
[os.path.join(output_dir, f"{model_name}.c")],
options=["-c", "-O3", "-I/home/user/libs/tvm/include"], # Add your cross-compilation flags
cc="gcc"
)
My issue now is that I get fatal error: tvm/runtime/c_runtime_api.h: No such file or directory 1 | #include “tvm/runtime/c_runtime_api.h” | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated.
Maybe this could be a version mismatch between my apache-tvm version in python (Python 3.10) and the tvm I cloned from github from which I gave the path. I am also dubious of what “export_library()” does exactly, and in general how to bundle together the tvm_runtime library to generate a minimal library from which I can link to perform inference on my network.
Thank you in advance !