Imported Upstream version 1.8.0
[platform/core/ml/nnfw.git] / runtime / contrib / android_benchmark_app / README.md
1 # Android Benchmark App
2
3 An Android sample app that run `.tflite` and measure performance.
4
5 You can run with two engines.
6
7 - Tensorflow Lite Interpreter
8 - NN API Delegate (onert)
9
10 ## Build
11
12 In addition to aarch64-Android build, you need to specify more parameters.
13
14 - `ANDROID_BUILD_TOOLS_DIR` : Android `build-tools` directory (You may find it in Android SDK directory)
15 - `ANDROID_SDK_DIR` : Android SDK directory
16 - `TFLITE_MODEL_PATH` : A model to run (Only one model can be packed)
17 - `ANDROID_BOOST_ROOT` : Boost library root path
18     - This repo should contain `lib` and `include` directory
19     - How to build Boost for Android - Build with [this repo](https://github.com/moritz-wundke/Boost-for-Android)
20
21 Example:
22
23 ```bash
24 make TARGET_OS=android \
25     CROSS_BUILD=1 \
26     BUILD_TYPE=RELEASE \
27     NDK_DIR=/home/hanjoung/ws/android-tools/r20/ndk \
28     EXT_ACL_FOLDER=/home/hanjoung/ws/temp/arm_compute-v19.05-bin-android/lib/android-arm64-v8a-neon-cl \
29     ANDROID_BUILD_TOOLS_DIR=/home/hanjoung/ws/android-tools/sdk/build-tools/27.0.3/ \
30     ANDROID_SDK_DIR=/home/hanjoung/ws/android-tools/sdk \
31     TFLITE_MODEL_PATH=/Users/hanjoung/ws/ghent/STAR/nnfw/tests/scripts/models/cache/MODELS/mobilenet/mobilenet_v1_0.25_128.tflite \
32     ANDROID_BOOST_ROOT=/home/hanjoung/ws/gh/moritz-wundke/Boost-for-Android/build/out/arm64-v8a
33 ```
34
35 And you will get `obj/contrib/android_benchmark_app/android-benchmark.unsigned.pkg`. This is an unsigned Android app package.
36
37 ## Sign APK
38
39 Before installing the package you probably need to sign the package.
40
41 - `apksigner` : This is in `build-tools` directory
42 - Your keystore : How-to is TBD
43
44 ```bash
45 apksigner sign \
46     --ks ~/.android/debug.keystore \
47     --in Product/aarch64-android.release/obj/contrib/android_benchmark_app/android-benchmark.unsigned.pkg \
48     --out tflbench.apk
49 ```
50
51 You should enter the keystore password. Then you will get `tflbench.apk`.
52
53 ## Install APK
54
55 ```bash
56 adb install tflbench.apk
57 adb uninstall com.ndk.tflbench # To uninstall
58 ```