Skip to content

Commit 0746421

Browse files
committed
Update the vision llm page and add content of UI demo
1 parent 8a2bab1 commit 0746421

File tree

2 files changed

+68
-11
lines changed

2 files changed

+68
-11
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
title: Benchmark the Vision Transformer performance with KleidiAI
3+
weight: 4
4+
5+
### FIXED, DO NOT MODIFY
6+
layout: learningpathall
7+
---
8+
9+
## Clone Vision Language Models repo
10+
11+
In this section, you will run the Qwen model in action using a demo application using a Android Package Kit (APK).
12+
13+
This repository is set up to enable building the app as an Android Studio project.
14+
15+
Run the following commands to clone the repository and checkout the source tree:
16+
17+
```bash
18+
git clone https://gitlab.arm.com/kleidi/kleidi-examples/vision-language-models
19+
```
20+
21+
## Build the App Using Android Studio
22+
23+
You can use Android Studio to build the app and create an APK.
24+
25+
### Open project and build
26+
27+
Open Android Studio.
28+
29+
Go to **File > Open**.
30+
31+
Navigate to the vision-language-models directories, and click `Open`.
32+
33+
This triggers a build of the project, and you should see output similar to the following on completion:
34+
35+
```output
36+
BUILD SUCCESSFUL in 1m 42s
37+
```
38+
39+
### Generate and Run the APK
40+
41+
Navigate to **Build > Generate App Bundles or APKs**. Select **Generate APKs**.
42+
43+
The build will be executed, and then the app will be copied and installed on the Android device.
44+
45+
After opening the app, you will see the splash screen:
46+
47+
![Loading screenshot](Loading_page.png)
48+
49+
Finally, you can use the UI to chat with the app. Try uploading an image and ask a question on it.
50+
51+
![Loading screenshot](chat2.png)
52+
53+
The final step is to examine how KleidiAI can improve the performance of the model. Continue to the next section to find out.
Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Build the MNN Command-line ViT Demo
3-
weight: 4
3+
weight: 5
44

55
### FIXED, DO NOT MODIFY
66
layout: learningpathall
@@ -29,7 +29,7 @@ Run the following commands to clone the MNN repository and checkout the source t
2929
cd $HOME
3030
git clone https://github.com/alibaba/MNN.git
3131
cd MNN
32-
git checkout a739ea5870a4a45680f0e36ba9662ca39f2f4eec
32+
git checkout fa3b2161a9b38ac1e7dc46bb20259bd5eb240031
3333
```
3434

3535
Create a build directory and run the build script.
@@ -40,10 +40,9 @@ The first time that you do this, build the binaries with the `-DMNN_KLEIDIAI` fl
4040
cd $HOME/MNN/project/android
4141
mkdir build_64 && cd build_64
4242

43-
../build_64.sh "-DMNN_LOW_MEMORY=true -DLLM_SUPPORT_VISION=true -DMNN_KLEIDIAI=FALSE \
44-
-DMNN_CPU_WEIGHT_DEQUANT_GEMM=true -DMNN_BUILD_LLM=true \
45-
-DMNN_SUPPORT_TRANSFORMER_FUSE=true -DMNN_ARM82=true -DMNN_OPENCL=true \
46-
-DMNN_USE_LOGCAT=true -DMNN_IMGCODECS=true -DMNN_BUILD_OPENCV=true"
43+
../build_64.sh "-DMNN_BUILD_LLM=true -DMNN_BUILD_LLM_OMNI=ON -DLLM_SUPPORT_VISION=true \
44+
-DMNN_BUILD_OPENCV=true -DMNN_IMGCODECS=true -DMNN_LOW_MEMORY=true \
45+
-DMNN_CPU_WEIGHT_DEQUANT_GEMM=true -DMNN_BUILD_LLM=true -DMNN_SUPPORT_TRANSFORMER_FUSE=true"
4746
```
4847
{{% notice Note %}}
4948
If your NDK toolchain isn't set up correctly, you might run into issues with the above script. Make a note of where the NDK was installed - this will be a directory named after the version you downloaded earlier. Try exporting the following environment variables before re-running `build_64.sh`:
@@ -102,14 +101,19 @@ prefill speed = 192.28 tok/s
102101

103102
## Enable KleidiAI and Re-run Inference
104103

105-
The next step is to re-generate the binaries with KleidiAI activated. This is done by updating the flag `-DMNN_KLEIDIAI` to `TRUE`.
104+
The next step is to re-generate the binaries with KleidiAI activated. This is done by inserting a hint into the code.
105+
106+
From the `MNN` directory, run:
107+
```bash
108+
sed -i '/void Llm::setRuntimeHint(std::shared_ptr<Express::Executor::RuntimeManager> &rtg) {/a\
109+
rtg->setHint(MNN::Interpreter::CPU_ENABLE_KLEIDIAI, 1);' transformers/llm/engine/src/llm.cpp
110+
```
106111

107112
From the `build_64` directory, run:
108113
```bash
109-
../build_64.sh "-DMNN_LOW_MEMORY=true -DLLM_SUPPORT_VISION=true -DMNN_KLEIDIAI=TRUE \
110-
-DMNN_CPU_WEIGHT_DEQUANT_GEMM=true -DMNN_BUILD_LLM=true \
111-
-DMNN_SUPPORT_TRANSFORMER_FUSE=true -DMNN_ARM82=true -DMNN_OPENCL=true \
112-
-DMNN_USE_LOGCAT=true -DMNN_IMGCODECS=true -DMNN_BUILD_OPENCV=true"
114+
../build_64.sh "-DMNN_BUILD_LLM=true -DMNN_BUILD_LLM_OMNI=ON -DLLM_SUPPORT_VISION=true \
115+
-DMNN_BUILD_OPENCV=true -DMNN_IMGCODECS=true -DMNN_LOW_MEMORY=true \
116+
-DMNN_CPU_WEIGHT_DEQUANT_GEMM=true -DMNN_BUILD_LLM=true -DMNN_SUPPORT_TRANSFORMER_FUSE=true"
113117
```
114118
## Update Files on the Device
115119

0 commit comments

Comments
 (0)