Skip to content

Commit 98af719

Browse files
kirklandsignfacebook-github-bot
authored andcommitted
Fix the android demo app tutorial (#649)
Summary: Add more details to XNNPACK JNI lib Pull Request resolved: #649 Reviewed By: mcr229 Differential Revision: D49980063 Pulled By: kirklandsign fbshipit-source-id: 65476dfe5dc396ba4beb7d7c20fd0ae0883dc1bb
1 parent eeb85a3 commit 98af719

File tree

1 file changed

+27
-3
lines changed
  • examples/demo-apps/android/ExecuTorchDemo

1 file changed

+27
-3
lines changed

examples/demo-apps/android/ExecuTorchDemo/README.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,13 @@ cmake .. \
7575
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON
7676
```
7777

78-
2. Configure a library with XNNPACK and Qualcomm HTP backend
78+
When we set `EXECUTORCH_BUILD_XNNPACK=ON`, we will build the target [`xnn_executor_runner_lib`](../../../../backends/xnnpack/CMakeLists.txt) which in turn is built into in [CMake](../jni/CMakeLists.txt).
79+
80+
`libexecutorchdemo.so` wraps up the required XNNPACK Backend runtime library from `xnn_executor_runner_lib`, and adds an additional JNI layer using fbjni. This is later exposed to Java app.
81+
82+
2. *Optional:* Configure a library with XNNPACK and [Qualcomm HTP backend](../../../../backends/qualcomm/README.md)
83+
84+
Qualcomm SDK is required for this step.
7985

8086
```bash
8187
rm -rf cmake-out && mkdir cmake-out && cd cmake-out
@@ -92,6 +98,8 @@ cmake .. \
9298
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON
9399
```
94100

101+
Similar to the previous XNNPACK library, with this setup, `libexecutorchdemo.so` wraps up the XNNPACK Backend and Qualcomm HTP runtime library and fbjni. This is later exposed to Java app.
102+
95103
## Building and Copying Libraries
96104

97105
1. Build the libraries:
@@ -115,6 +123,15 @@ cp ./examples/demo-apps/android/jni/libexecutorchdemo.so \
115123
../examples/demo-apps/android/ExecuTorchDemo/app/src/main/jniLibs/arm64-v8a
116124
```
117125

126+
3. *Qualcomm HTP Only:* Copy Qualcomm HTP runtime library
127+
128+
If Qualcomm HTP backend is used, then we need to copy additional libraries from Qualcomm SDK artifacts:
129+
130+
```bash
131+
cp libQnnHtp.so libQnnHtpV69Skel.so libQnnHtpStub.so libQnnSystem.so \
132+
../examples/demo-apps/android/ExecuTorchDemo/app/src/main/jniLibs/arm64-v8a
133+
```
134+
118135
Later, this shared library will be loaded by `NativePeer.java` in Java code.
119136

120137
Then return to the `executorch` directory:
@@ -134,11 +151,18 @@ Note: Please refer to [XNNPACK backend](../../../backend/README.md) and [Qualcom
134151
export FLATC_EXECUTABLE=$(realpath third-party/flatbuffers/cmake-out/flatc)
135152
python3 -m examples.backend.xnnpack_examples --model_name="dl3" --delegate
136153
python3 -m examples.backend.xnnpack_examples --model_name="ic4" --delegate
137-
cp dl3_xnnpack_fp32.pte ic4_xnnpack_fp32.pte examples/android_demo_apps/ExecuTorchDemo/app/src/main/assets/
154+
mkdir -p examples/demo-apps/android/ExecuTorchDemo/app/src/main/assets/
155+
cp dl3_xnnpack_fp32.pte ic4_xnnpack_fp32.pte examples/demo-apps/android/ExecuTorchDemo/app/src/main/assets/
156+
```
157+
158+
2. *Qualcomm HTP Only:* Copy HTP delegation models to the app:
159+
160+
```bash
161+
cp dlv3_qnn.pte ic4_qnn.pte examples/demo-apps/android/ExecuTorchDemo/app/src/main/assets/
138162
```
139163

140164
## Final Steps
141165

142-
1. Open the project `examples/android_demo_apps/ExecuTorchDemo` with Android Studio.
166+
1. Open the project `examples/demo-apps/android/ExecuTorchDemo` with Android Studio.
143167

144168
2. [Run](https://developer.android.com/studio/run) the app (^R)

0 commit comments

Comments
 (0)