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
@@ -104,52 +95,68 @@ Note: Exporting model flow can take 2.5 hours (114GB RAM for num_chunks=4) to co
104
95
105
96
Before continuing forward, make sure to modify the tokenizer, token embedding, and model paths in the examples/mediatek/executor_runner/run_llama3_sample.sh.
106
97
107
-
## Deploy Files on Device
98
+
### Deploy
99
+
First, make sure your Android phone’s chipset version is compatible with this demo (MediaTek Dimensity 9300 (D9300)) chip. Once you have the model, tokenizer, and runner generated ready, you can push them and the .so files to the device before we start running using the runner via shell.
108
100
109
-
### Prepare to Deploy
110
-
Prior to deploying the files on device, make sure to modify the tokenizer, token embedding, and model file names in examples/mediatek/executor_runner/run_llama3_sample.sh reflect what was generated during the Export Llama Model step.
101
+
```
102
+
adb shell mkdir -p /data/local/tmp/et-mtk/ (or any other directory name)
The Mediatek runner (`examples/mediatek/executor_runner/mtk_llama_runner.cpp`) contains the logic for implementing the function calls that come from the Android app.
120
118
121
-
You are a helpful AI assistant for travel tips and recommendations<|eot_id|><|start_header_id|>user<|end_header_id|>
119
+
**Important!** Currently the model paths are set in the runner-level. Modify the values in `examples/mediatek/executor_runner/llama_runner/llm_helper/include/llama_runner_values.h` to set the model paths, tokenizer path, embedding file path, and other metadata.
122
120
123
-
What can you help me with?<|eot_id|><|start_header_id|>assistant<|end_header_id|>
124
-
```
125
121
126
-
### Deploy
127
-
First, make sure your Android phone’s chipset version is compatible with this demo (MediaTek Dimensity 9300 (D9300)) chip. Once you have the model, tokenizer, and runner generated ready, you can push them and the .so files to the device before we start running using the runner via shell.
122
+
## Build AAR Library
128
123
124
+
Next we need to build and compile the MediaTek backend and MediaTek Llama runner. By setting `NEURON_BUFFER_ALLOCATOR_LIB`, the script will build the MediaTek backend.
**Output**: This will generate an .aar file that is already imported into the expected directory for the Android app. It will live in `examples/demo-apps/android/Llamademo/app/libs`.
130
+
131
+
If you were to unzip the .aar file or open it in Android Studio, verify it contains the following related to MediaTek backend:
132
+
* libneuron_buffer_allocator.so
133
+
* libneuronusdk_adapter.mtk.so
134
+
* libneuron_backend.so (generated during build)
135
+
141
136
## Run Demo
142
-
At this point we have pushed all the required files on the device and we are ready to run the demo!
143
-
```
144
-
adb shell
145
137
146
-
<android_device>:/ $ cd data/local/tmp/llama
147
-
<android_device>:/data/local/tmp/llama $ sh run_llama3_sample.sh
138
+
### Alternative 1: Android Studio (Recommended)
139
+
1. Open Android Studio and select “Open an existing Android Studio project” to open examples/demo-apps/android/LlamaDemo.
140
+
2. Run the app (^R). This builds and launches the app on the phone.
141
+
142
+
### Alternative 2: Command line
143
+
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.
148
144
```
145
+
export ANDROID_HOME=<path_to_android_sdk_home>
146
+
pushd examples/demo-apps/android/LlamaDemo
147
+
./gradlew :app:installDebug
148
+
popd
149
+
```
150
+
If the app successfully run on your device, you should see something like below:
3. Click the "Load Model" button. This will load the models from the Runner
160
+
154
161
## Reporting Issues
155
162
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