Implementation of Hexagon Runtime for Target

Hi @kparzysz

Thank you very much for your detailed reply!

I am currently stuck somewhere trying to make this work. So for starters, I would like to verify further if the preceding steps I have taken so far are correct:

My understanding from reading the READ.MD of Hexagon Backend Runtime, for either using simulator or actual device, I would need to build two runtime(s).

  1. Uploaded stub libraries to /vendor/bin/
  2. Uploaded skel libraries to /vendor/lib/rfsa/adsp/
  3. Built TVM Runtime for Android - which I pushed to /vendor/bin together with tvm_rpc
  4. Built TVM Runtime for Hexagon (the one with disabled device support for Hexagon device) - which I pushed to /vendor/lib/rfsa/adsp/

I was wondering if uploading both runtime(s) in 3 and 4 (with the same filename libtvm_runtime.so would cause some form of conflict?). Or I totally got this part all wrong. I read the Hexagon docs and it says that an executable would successively look for dynamic libraries at different locations (the same paths I pushed the files to.)

Then, after doing steps 1 to 4, setting up rpc tracker and server, and finally testing matmul, I am getting this error:

root@tvm:/workspace/tvm/apps/android_rpc/tests# python3 matmul.py
Traceback (most recent call last):
File "matmul.py", line 39, in <module>
f.save('cpu.so')
File "/workspace/tvm/python/tvm/runtime/module.py", line 166, in save
_ffi_api.ModuleSaveToFile(self, file_name, fmt)
File "tvm/_ffi/_cython/./packed_func.pxi", line 322, in tvm._ffi._cy3.core.PackedFuncBase.__call__
File "tvm/_ffi/_cython/./packed_func.pxi", line 257, in tvm._ffi._cy3.core.FuncCall
File "tvm/_ffi/_cython/./packed_func.pxi", line 246, in tvm._ffi._cy3.core.FuncCall3
File "tvm/_ffi/_cython/./base.pxi", line 160, in tvm._ffi._cy3.core.CALL
tvm._ffi.base.TVMError: Traceback (most recent call last):
[bt] (3) /workspace/tvm/build/libtvm.so(TVMFuncCall+0x61) [0x7fe8c456fd61]
[bt] (2) /workspace/tvm/build/libtvm.so(+0x1442f83) [0x7fe8c453ff83]
[bt] (1) /workspace/tvm/build/libtvm.so(tvm::codegen::LLVMModuleNode::SaveToFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)+0x6d6) [0x7fe8c4518a06]
[bt] (0) /workspace/tvm/build/libtvm.so(dmlc::LogMessageFatal::~LogMessageFatal()+0x67) [0x7fe8c36e24b7]
File "/workspace/tvm/src/target/llvm/llvm_module.cc", line 151
TVMError: Do not know how to save file cpu.so with format=''

This error tells me that instead of the runtime for my PC side that is supposed to run hexagon_module.cc is using llvm_module.cc, which likely explains its inability to properly save the module.

I cannot pinpoint exactly what is causing this. I think the error above is related to how I set up the runtime appropriately. Any hints?

But by any chance, could this be related to the full version of TVM build in my PC? Also, if it helps, I actually built the TVM package with set(USE_HEXAGON_DEVICE sim) temporarily because if I use set(USE_HEXAGON_DEVICE target) instead, I get the exact same error here whenever I simply call import tvm.

Thank you so much again in advance!