You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Summary:
Automatically invoke `examples/demo-apps/android/LlamaDemo/setup.sh` in `gradle setup` task. Users doesn't need to run examples/demo-apps/android/LlamaDemo/setup.sh manually.
Test (follow https://github.com/pytorch/executorch/blob/ba824577f495f7522cc9be91d38cf8ad187bc841/examples/demo-apps/android/LlamaDemo/README.md):
1. Fetch source
```
git fetch origin pull/2838/head
git checkout FETCH_HEAD
```
2. Push model
```
adb shell mkdir -p /data/local/tmp/llama
adb push llama2.pte /data/local/tmp/llama <--- Use your pte file
adb push tokenizer.bin /data/local/tmp/llama <--- Use your tokenizer.bin
```
3. Build JNI
```
export ANDROID_NDK=<path_to_android_ndk> <---- You can download NDK from https://developer.android.com/ndk/downloads
export ANDROID_ABI=arm64-v8a
pushd examples/demo-apps/android/LlamaDemo
./gradlew :app:setup
popd
```
4. Build app
* (Method 1) Open Android Studio and select "Open an existing Android Studio project" to open examples/demo-apps/android/LlamaDemo. Run the app (^R). This builds and launches the app on the phone.
* (Method 2)
```
export ANDROID_HOME=--sanitized--
Pull Request resolved: #2838
Reviewed By: cccclai
Differential Revision: D55717885
Pulled By: kirklandsign
fbshipit-source-id: fc2c47219860c8245a1b7728abee46467c846908
3. Run the following command set up the required JNI library:
36
+
```bash
37
+
pushd examples/demo-apps/android/LlamaDemo
38
+
./gradlew :app:setup
39
+
popd
88
40
```
41
+
This is running the shell script [setup.sh](./setup.sh) which configures the required core ExecuTorch, LLAMA2, and Android libraries, builds them, and copy to jniLibs.
89
42
90
43
## Build Java app
44
+
### Alternative 1: Android Studio (Recommended)
91
45
1. Open Android Studio and select "Open an existing Android Studio project" to open examples/demo-apps/android/LlamaDemo.
92
-
2. Run the app (^R).
46
+
2. Run the app (^R). This builds and launches the app on the phone.
47
+
48
+
### Alternative 2: Command line
49
+
Without Android Studio UI, we can run gradle directly to build the app. We need to set up the Android SDK path and invoke gradle.
50
+
```bash
51
+
export ANDROID_HOME=<path_to_android_sdk_home>
52
+
pushd examples/demo-apps/android/LlamaDemo
53
+
./gradlew :app:installDebug
54
+
popd
55
+
```
93
56
94
57
On the phone or emulator, you can try running the model:
Through this tutorial we've learnt how to build the ExecuTorch LLAMA library with XNNPACK backend, and expose it to JNI layer to build the Android app.
61
+
Through this tutorial we've learnt how to build the ExecuTorch LLAMA library, and expose it to JNI layer to build the Android app.
99
62
100
63
## Reporting Issues
101
64
If you encountered any bugs or issues following this tutorial please file a bug/issue here on [Github](https://github.com/pytorch/executorch/issues/new).
0 commit comments