Skip to content

Commit 3f04c3c

Browse files
Update README for MediaTek backend (#5386)
Summary: 1. Move common setup instructions under backends/ 2. Refactoring 3. Add link for NeuroPilot Express SDK portal Pull Request resolved: #5386 Reviewed By: kirklandsign Differential Revision: D63515265 Pulled By: cccclai fbshipit-source-id: 7834397613489650a815f50212c8bb20490afafd
1 parent 87dc49d commit 3f04c3c

File tree

3 files changed

+41
-34
lines changed

3 files changed

+41
-34
lines changed

backends/mediatek/scripts/README.md

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,41 +10,60 @@ Before you begin, ensure you have the following prerequisites installed and conf
1010

1111
- **Download Buck2**: Obtain Buck2 from the official [releases page](https://github.com/facebook/buck2/releases/tag/2024-02-01).
1212
- **Add to PATH**: Extract the downloaded file and add the directory to your system's `$PATH` environment variable.
13-
```bash
14-
export PATH=<path_to_buck>:$PATH
15-
```
13+
```bash
14+
export PATH=<path_to_buck>:$PATH
15+
```
1616

1717
### 2. Android NDK
1818

1919
- **Download Android NDK**: Acquire the Android NDK from the [Android developer site](https://developer.android.com/ndk/downloads).
2020
- **Set NDK Path**: Ensure that the `$ANDROID_NDK` environment variable is set to the path where the NDK is located.
21-
```bash
22-
export ANDROID_NDK=<path_to_android_ndk>
23-
```
21+
```bash
22+
export ANDROID_NDK=<path_to_android_ndk>
23+
```
2424

2525
### 3. MediaTek ExercuTorch Libraries
2626

27-
Download the following libraries from MediaTek's NeuroPilot portal (link to be added):
27+
Download [NeuroPilot Express SDK](https://neuropilot.mediatek.com/resources/public/npexpress/en/docs/npexpress) from MediaTek's NeuroPilot portal:
2828

2929
- `libneuronusdk_adapter.mtk.so`: This universal SDK contains the implementation required for executing target-dependent code on the MediaTek chip.
3030
- `libneuron_buffer_allocator.so`: This utility library is designed for allocating DMA buffers necessary for model inference.
31-
```bash
32-
export NEURON_BUFFER_ALLOCATOR_LIB=<path_to_buffer_allocator>
33-
```
31+
- `mtk_converter-8.8.0.dev20240723+public.d1467db9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl`: This library preprocess the model into a MediaTek representation.
32+
- `mtk_neuron-8.2.2-py3-none-linux_x86_64.whl`: This library converts the model to binaries.
3433

3534
## Setup
3635

37-
Follow the steps below to set up your build environment:
36+
Follow the steps below to setup your build environment:
37+
38+
1. **Setup ExercuTorch Environment**: Refer to the [Setting up ExercuTorch](https://pytorch.org/executorch/stable/getting-started-setup) guide for detailed instructions on setting up the ExercuTorch environment.
39+
40+
2. **Setup MediaTek Backend Environment**
41+
- Install the dependent libs. Ensure that you are inside backends/mediatek/ directory
42+
```bash
43+
pip3 install -r requirements.txt
44+
```
45+
- Install the two .whl downloaded from NeuroPilot Portal
46+
```bash
47+
pip3 install mtk_neuron-8.2.2-py3-none-linux_x86_64.whl
48+
pip3 install mtk_converter-8.8.0.dev20240723+public.d1467db9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
49+
```
50+
- Set evironment variables for building backend
51+
```bash
52+
export NEURON_BUFFER_ALLOCATOR_LIB=<path_to_buffer_allocator>
53+
```
3854

39-
1. **ExercuTorch Official Tutorial**: Refer to the [Setting up ExercuTorch](https://pytorch.org/executorch/stable/getting-started-setup) guide for detailed instructions on setting up the ExercuTorch environment.
55+
## Build
4056

41-
2. **Build Script**: Once the prerequisites are in place, run the `mtk_build.sh` script to start the build process.
57+
1. **Build MediaTek Backend**: Once the prerequisites are in place, run the `mtk_build.sh` script to start the build process, MediaTek backend will be built under `cmake-android-out/backends/` as `libneuron_backend.so`
4258

4359
```bash
4460
./mtk_build.sh
4561
```
46-
3. **Push MediaTek universal SDK to the device**: push libneuronusdk_adapter.mtk.so to the phone and export it to the `$LD_LIBRARY_PATH` environment variable before executing ExercuTorch with MediaTek backend.
62+
63+
## Run
64+
65+
1. **Push MediaTek universal SDK and MediaTek backend to the device**: push `libneuronusdk_adapter.mtk.so` and `libneuron_backend.so` to the phone and export it to the `$LD_LIBRARY_PATH` environment variable before executing ExercuTorch with MediaTek backend.
4766

4867
```bash
49-
export LD_LIBRARY_PATH=<path_to_usdk>:$LD_LIBRARY_PATH
68+
export LD_LIBRARY_PATH=<path_to_usdk>:<path_to_neuron_backend>:$LD_LIBRARY_PATH
5069
```

examples/mediatek/README.md

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,18 @@ examples/mediatek
2323
├── mtk_build_examples.sh # Script for building MediaTek backend and the examples
2424
└── README.md # Documentation for the examples (this file)
2525
```
26-
# Examples
27-
## Build MediaTek examples
28-
1. Set up the environment by folllowing the instructions in `backends/mediatek/scripts`
29-
2. Build the backend and the examples by exedcuting the script:
30-
```bash
31-
./mtk_build_examples.sh
32-
```
26+
# Examples Build Instructions
3327

34-
# AoT
3528
## Environment Setup
36-
1. Setup ET Environment
37-
- Follow the instructions found in: https://pytorch.org/executorch/stable/getting-started-setup.html
38-
2. Setup MTK AoT Environment
39-
```bash
40-
// Ensure that you are inside executorch/examples/mediatek directory
41-
pip3 install -r requirements.txt
29+
- Follow the instructions of **Prerequisites** and **Setup** in `backends/mediatek/scripts/README.md`.
4230

43-
// Download the two whl files from NeuroPilot Portal
44-
pip3 install mtk_neuron-8.2.2-py3-none-linux_x86_64.whl
45-
pip3 install mtk_converter-8.8.0.dev20240723+public.d1467db9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
31+
## Build MediaTek Examples
32+
1. Build the backend and the examples by exedcuting the script:
33+
```bash
34+
./mtk_build_examples.sh
4635
```
4736

48-
## AoT Flow
49-
### llama
37+
## LLaMa Example Instructions
5038
##### Note: Verify that localhost connection is available before running AoT Flow
5139
1. Exporting Models to `.pte`
5240
- In the `examples/mediatek directory`, run:

0 commit comments

Comments
 (0)