I am currently trying to run TVM Hexagon on an Android device (Snapdragon). 
Just to get started, I wish to offload a simple matrix multiplication on the 
aDSP with TVM.

So far my understanding from reading the page "Introducing Hexagon Backend", I 
need to build the following:
1) IDL Libraries
2) stub library
3) skel library

I followed the instructions from the git repo and I now have libtvm_runtime.so 
including the stub and skel libraries. 

Following the documentations from Hexagon SDK, I pushed these files to the 
device:
for the stub: `/vendor/lib/`
for the skel: `/vendor/lib/rfsa/adsp/`

After this, I have no clue yet how to proceed forward. Basically my question is 
how can I run my matmul on the device by running some Python script on my local 
machine? If the only way is to run on the adb shell, what is the procedure?

I have three ideas for tackling this problem: 
My (1) idea was to modify the android_rpc app in some way so that I can run a 
python script in my local machine and communicate with the phone with RPC. And 
in that script I can do something like (similar to running on cpu or gpu)
ctx = remote.hexagon(0)
remote.upload(path_dso_dsp)

My idea was that, in the rpc_app, it just needs to change between cpu and 
opencl, so maybe for hexagon it's as easy as setting the context appropriately.
If this is actually the right way to do it, do I only need to change the 
runtime found in the src? (e.g. in /app/src/main/libs/arm64-v8a/lib). Right now 
I can see that it has libc++_shared.so and libtvm4j_runtime_packed.so. 

The second solution I can think of is how other examples from the Hexagon SDK 
documentation are implemented. First, they also build the stub and dynamic 
libraries (skel) and after that, they build some executable that can be run in 
the adb shell. I have looked through their project structures and it seems like 
the src files for actually running something (for example the calculator) is 
based on C language. If this is the only way, does this mean I have to write in 
C the same kind of executable to be able to offload my matmul (using TVM) to 
the DSP?

The third solution I can think of is installing python in Android like 
[here](https://medium.com/swlh/python-on-android-root-4aa56f22070a). And from 
the adb shell I can run this 
[script](https://gist.github.com/apivovarov/080b7d98de9d097bbb495ea45545df5c). 
Would this form of solution cause some sort of problems like some dependencies 
of python or TVM might be unresolved? 

I am very new to this field. I apologize if I have some misunderstandings in 
any of the concepts in this matter.
Thank you so much in advance for your help!





---
[Visit 
Topic](https://discuss.tvm.apache.org/t/implementation-of-hexagon-runtime-for-target/9284/1)
 to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click 
here](https://discuss.tvm.apache.org/email/unsubscribe/c9e3dd1f1b7277ab9795d50690c296cfcae6353d35815c6f84c429ae5e2b4303).

Reply via email to