@@ -127,7 +127,12 @@ Deploying the compiled model here require use some tools on host as well as on t
127127TVM has simplified user friendly command line based tools as well as
128128developer centric python API interface for various steps like auto tuning, building and deploying.
129129
130- TVM compilation process for remote devices has multiple stages listed below.
130+
131+ |Android deployment pipeline |
132+
133+ *Fig.2 Build and Deployment pipeline on Adreno devices *
134+
135+ The figure above demonstrates a generalized pipeline for various stages listed below.
131136
132137**Model import: **
133138At this stage we import a model from well known frameworks like Tensorflow, PyTorch, ONNX ...etc.
@@ -150,7 +155,7 @@ At this stage we run the TVM compilation output on the target. Deployment is pos
150155environment using RPC Setup and also using TVM's native tool which is native binary cross compiled for Android.
151156At this stage we can run the compiled model on Android target and unit test output correctness and performance aspects.
152157
153- **Aplication Integration: **
158+ **Application Integration: **
154159This stage is all about integrating TVM compiled model in applications. Here we discuss about
155160interfacing tvm runtime from Android (cpp native environment or from JNI) for setting input and getting output.
156161
@@ -234,7 +239,6 @@ Below command will configure the build the host compiler
234239 cd build
235240 cp ../cmake/config.cmake .
236241
237- echo set\(USE_OPENCL ON\) >> config.cmake
238242 echo set\(USE_RPC ON\) >> config.cmake
239243 echo set\(USE_GRAPH_EXECUTOR ON\) >> config.cmake
240244 echo set\(USE_LIBBACKTRACE AUTO\) >> config.cmake
@@ -258,7 +262,7 @@ Finally we can export python path as
258262
259263::
260264
261- export PYTHONPATH=$PWD: /python
265+ export PYTHONPATH=$TVM_HOME /python:${PYTHONPATH}
262266 python3 -c "import tvm" # Verify tvm python package
263267
264268
@@ -274,7 +278,6 @@ Target build require Android NDK to be installed.
274278 mkdir -p build-adreno
275279 cd build-adreno
276280 cp ../cmake/config.cmake .
277- echo set\(USE_MICRO OFF\) >> config.cmake
278281 echo set\(USE_OPENCL ON\) >> config.cmake
279282 echo set\(USE_RPC ON\) >> config.cmake
280283 echo set\(USE_CPP_RPC ON\) >> config.cmake
@@ -342,73 +345,29 @@ manually and also inside docker using automated tools.
342345**Automated RPC Setup: **
343346Here we will explain how to setup RPC in docker environment.
344347
345- Below command launches tracker in docker environment, where docker listens on port 9120 .
348+ Below command launches tracker in docker environment, where tracker listens on port 9190 .
346349
347350::
348351
349352 ./tests/scripts/ci.py adreno -i # Launch a new shell on the anreno docker
350- source tests/scripts/setup-adreno-env.sh -e tracker -p 9120
353+ source tests/scripts/setup-adreno-env.sh -e tracker -p 9190
351354
352355Now, the below comand can run TVM RPC on remote android device with id "abcdefgh".
353356
354357
355358::
356359
357360 ./tests/scripts/ci.py adreno -i # Launch a new shell on adreno docker.
358- source tests/scripts/setup-adreno-env.sh -e device -p 9120 -d abcdefgh
361+ source tests/scripts/setup-adreno-env.sh -e device -p 9190 -d abcdefgh
359362
360363
361364**Manual RPC Setup: **
362365
363- Below command in manual setup starts the tracker on port 9120
364-
365- ::
366-
367- python3 -m tvm.exec.rpc_tracker --host "0.0.0.0" --port "9120"
368-
369- TVM RPC launch on Android device require some environment setup due to Android device is connected via ADB interface and we need to re-route
370- TCP/IP communication over ADB interface. Below commands will do necessary setup and run tvm_rpc on remote device.
371-
372- ::
373-
374- # Set android device to use
375- export ANDROID_SERIAL=abcdefgh
376- # Create a temporary folder on remote device.
377- adb shell "mkdir -p /data/local/tmp/tvm_ci"
378- # Copy tvm_rpc and it's dependency to remote device
379- adb push build-adreno-target/tvm_rpc /data/local/tmp/tvm_test/tvm_rpc
380- adb push build-adreno-target/libtvm_runtime.so /data/local/tmp/tvm_test
381- # Forward port 9120 from target to host
382- adb reverse tcp:9210 tcp:9120
383- # tvm_rpc by default listens on ports starting from 5000 for incoming connections.
384- # Hence, reroute connections to these ports on host to remore device.
385- adb forward tcp:5000 tcp:5000
386- adb forward tcp:5001 tcp:5001
387- adb forward tcp:5002 tcp:5002
388- # Finally launch rpc_daemon on remote device with identity key as "android"
389- adb shell "cd /data/local/tmp/tvm_test; killall -9 tvm_rpc; sleep 2; LD_LIBRARY_PATH=/data/local/tmp/tvm_test/ ./tvm_rpc server --host=0.0.0.0 --port=5000 --port-end=5010 --tracker=127.0.0.1:9120 --key=android"
390-
391- Upon successfull running this remote device will be available on tracker which can be queried as below.
392-
393- ::
394-
395- python3 -m tvm.exec.query_rpc_tracker --port 9120
396- Tracker address 127.0.0.1:9120
397- Server List
398- ------------------------------
399- server-address key
400- ------------------------------
401- 127.0.0.1:5000 server:android
402- ------------------------------
403-
404- Queue Status
405- -------------------------------
406- key total free pending
407- -------------------------------
408- android 1 1 0
409- -------------------------------
366+ Please refer to the tutorial
367+ `How To Deploy model on Adreno using TVMC <https://tvm.apache.org/docs/how_to/deploy_models/deploy_model_on_adreno.html >`_
368+ for manual RPC environment setup.
410369
411- This concludes RPC Setup and we have rpc-tracker available on host 127.0.0.1 (rpc-tracker) and port 9120 (rpc-port).
370+ This concludes RPC Setup and we have rpc-tracker available on host 127.0.0.1 (rpc-tracker) and port 9190 (rpc-port).
412371
413372
414373.. _commandline_interface :
@@ -431,7 +390,7 @@ Here we use a model from Keras and it uses RPC setup for tuning and finally gene
431390 resnet50.h5 -o \
432391 keras-resnet50.log \
433392 --early-stopping 0 --repeat 30 --rpc-key android \
434- --rpc-tracker 127.0.0.1:9120 --trials 1024 \
393+ --rpc-tracker 127.0.0.1:9190 --trials 1024 \
435394 --tuning-records keras-resnet50-records.log --tuner xgb
436395
437396**Model Compilation: **
@@ -466,7 +425,7 @@ We can use below tvmc command to deploy on remore target via RPC based setup.
466425::
467426
468427 python3 -m tvm.driver.tvmc run --device="cl" keras-resnet50.tar \
469- --rpc-key android --rpc-tracker 127.0.0.1:9120 --print-time
428+ --rpc-key android --rpc-tracker 127.0.0.1:9190 --print-time
470429
471430tvmc based run has more option to initialize the input in various modes line fill, random ..etc.
472431
0 commit comments