chaozju opened a new issue #5804:
URL: https://github.com/apache/incubator-tvm/issues/5804


   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
   ```python
   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
   ```bash
   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
   ```bash
   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
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to