Is there a way to dump the Module to llvm ir into a .s
file which can be later built to standalone executable by clang
?
where I am:
- dump an output from python following toturial
model_name = 'resnet18'
model = getattr(torchvision.models, model_name)(pretrained=True)
model = model.eval()
scripted_model = torch.jit.trace(model, input_data).eval()
mod, params = relay.frontend.from_pytorch(scripted_model,shape_list)
with relay.build_config(opt_level=3):
graph, lib, params = relay.build(mod,target='llvm',target_host='llvm',params=params)
with open('/home/chao/tvm-playground/tvm-project/a.s','w') as f:
f.write(lib.get_source())
- assembling and linking with llvm backend
llvm-as -o a.bc a.s
llc -o a.o a.bc
as a.o -o a.as
cp ~/tvm/build/libtvm*.so ./
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD
ld -L "./libtvm.so" "./libtvm_runtime.so" "./libtvm_topi.so" -o a.out a.as
- result
chao@DESKTOP-B79IRTG:~/tvm-playground/tvm-project$ ld -L "./libtvm.so" "./libtvm_runtime.so" "./libtvm_topi.so" -o a.out a.as
ld: a.as: undefined reference to symbol 'memset@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libc.so.6: error adding symbols: DSO missing from command line