mkdir -p ~/armnn-devenv/toolchains
cd ~/armnn-devenv/toolchains
# For Mac OS, change the NDK download link accordingly.
- wget https://dl.google.com/android/repository/android-ndk-r16b-linux-x86_64.zip
- unzip android-ndk-r16b-linux-x86_64.zip
- export NDK=~/armnn-devenv/toolchains/android-ndk-r16b
+ wget https://dl.google.com/android/repository/android-ndk-r17b-linux-x86_64.zip
+ unzip android-ndk-r17b-linux-x86_64.zip
+ export NDK=~/armnn-devenv/toolchains/android-ndk-r17b
```
- You may want to append `export NDK=~/armnn-devenv/toolchains/android-ndk-r16b` to your `~/.bashrc` (or `~/.bash_profile` in Mac OS).
+ You may want to append `export NDK=~/armnn-devenv/toolchains/android-ndk-r17b` to your `~/.bashrc` (or `~/.bash_profile` in Mac OS).
* Make a standalone toolchain:
--arch arm64 \
--api 26 \
--stl=libc++ \
- --install-dir=$HOME/armnn-devenv/toolchains/aarch64-android-r16b
- export PATH=$HOME/armnn-devenv/toolchains/aarch64-android-r16b/bin:$PATH
+ --install-dir=$HOME/armnn-devenv/toolchains/aarch64-android-r17b
+ export PATH=$HOME/armnn-devenv/toolchains/aarch64-android-r17b/bin:$PATH
```
- You may want to append `export PATH=$HOME/armnn-devenv/toolchains/aarch64-android-r16b/bin:$PATH` to your `~/.bashrc` (or `~/.bash_profile` in Mac OS).
+ You may want to append `export PATH=$HOME/armnn-devenv/toolchains/aarch64-android-r17b/bin:$PATH` to your `~/.bashrc` (or `~/.bash_profile` in Mac OS).
#### <a name="buildBoost">Build the Boost C++ libraries</a>
```bash
cd ~/armnn-devenv/google/
git clone https://github.com/tensorflow/tensorflow.git
+ cd tensorflow/
+ git checkout 590d6eef7e91a6a7392c8ffffb7b58f2e0c8bc6b
```
+ You need tensorflow/contrib/makefile/tf_proto_files.txt from TensorFlow to generate TensorFlow protobuf definitions. This file is not available in TensorFlow master branch.
+
#### <a name="buildArmNN">Build ArmNN</a>
* Clone ArmNN source code:
CC=aarch64-linux-android-clang \
CXX_FLAGS="-fPIE -fPIC" \
cmake .. \
- -DCMAKE_SYSTEM_NAME=Linux \
- -DCMAKE_EXE_LINKER_FLAGS=-pie \
+ -DCMAKE_SYSTEM_NAME=Android \
+ -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a \
+ -DCMAKE_ANDROID_STANDALONE_TOOLCHAIN=$HOME/armnn-devenv/toolchains/aarch64-android-r17b/ \
+ -DCMAKE_EXE_LINKER_FLAGS="-pie -llog" \
-DARMCOMPUTE_ROOT=$HOME/armnn-devenv/ComputeLibrary/ \
-DARMCOMPUTE_BUILD_DIR=$HOME/armnn-devenv/ComputeLibrary/build \
-DBOOST_ROOT=$HOME/armnn-devenv/boost/install/ \
- -DARMCOMPUTENEON=1 -DARMCOMPUTECL=1 \
+ -DARMCOMPUTENEON=1 -DARMCOMPUTECL=1 -DARMNNREF=1 \
-DTF_GENERATED_SOURCES=$HOME/armnn-devenv/google/tf_pb/ -DBUILD_TF_PARSER=1 \
-DPROTOBUF_ROOT=$HOME/armnn-devenv/google/arm64_pb_install/
- make -j16
```
+ To include standalone sample dynamic backend tests, add the argument to enable the tests and the dynamic backend path to the CMake command:
+
+ ```bash
+ -DSAMPLE_DYNAMIC_BACKEND=1 \
+ -DDYNAMIC_BACKEND_PATHS=$SAMPLE_DYNAMIC_BACKEND_PATH
+ ```
+ Where $SAMPLE_DYNAMIC_BACKEND_PATH is the path where libArm_SampleDynamic_backend.so library file is pushed
+
+ * Run the build
+ ```bash
+ make -j16
+ ```
+
+#### <a name="buildStandaloneBackend">Build Standalone Sample Dynamic Backend</a>
+* The sample dynamic backend is located in armnn/src/dynamic/sample
+ ```bash
+ mkdir build
+ cd build
+ ```
+
+* Use CMake to configure the build environment, update the following script and run it from the armnn/src/dynamic/sample/build directory to set up the armNN build:
+ ```bash
+ #!/bin/bash
+ CXX=aarch64-linux-android-clang++ \
+ CC=aarch64-linux-android-clang \
+ CXX_FLAGS="-fPIE -fPIC" \
+ cmake \
+ -DCMAKE_SYSTEM_NAME=Android \
+ -DCMAKE_CXX_FLAGS=--std=c++14 \
+ -DCMAKE_EXE_LINKER_FLAGS="-pie -llog" \
+ -DCMAKE_MODULE_LINKER_FLAGS="-llog" \
+ -DBOOST_ROOT=$HOME/armnn-devenv/boost/install \
+ -DBoost_SYSTEM_LIBRARY=$HOME/armnn-devenv/boost/install/lib/libboost_system.a \
+ -DBoost_FILESYSTEM_LIBRARY=$HOME/armnn-devenv/boost/install/lib/libboost_filesystem.a \
+ -DARMNN_PATH=$HOME/armnn-devenv/armnn/build/libarmnn.so ..
+ ```
+
+* Run the build
+ ```bash
+ make
+ ```
+
#### <a name="runArmNNUnitTests">Run the ArmNN unit tests on an Android device</a>
* Push the build results to an Android device and make symbolic links for shared libraries:
+ Currently adb version we have used for testing is 1.0.41.
```bash
- adb push libarmnnTfParser.so libarmnn.so UnitTests \
- $NDK/sources/cxx-stl/llvm-libc++/libs/arm64-v8a/libc++_shared.so \
- /data/local/tmp/
- adb push $HOME/armnn-devenv/google/arm64_pb_install/lib/libprotobuf.so \
- /data/local/tmp/libprotobuf.so.15.0.1
+ adb push libarmnnTfParser.so /data/local/tmp/
+ adb push libarmnn.so /data/local/tmp/
+ adb push UnitTests /data/local/tmp/
+ adb push $NDK/sources/cxx-stl/llvm-libc++/libs/arm64-v8a/libc++_shared.so /data/local/tmp/
+ adb push $HOME/armnn-devenv/google/arm64_pb_install/lib/libprotobuf.so /data/local/tmp/libprotobuf.so.15.0.1
adb shell 'ln -s libprotobuf.so.15.0.1 /data/local/tmp/libprotobuf.so.15'
adb shell 'ln -s libprotobuf.so.15.0.1 /data/local/tmp/libprotobuf.so'
```
+* Push the files needed for the unit tests (they are a mix of files, directories and symbolic links):
+
+ ```bash
+ adb shell mkdir -p /data/local/tmp/src/backends/backendsCommon/test/testSharedObject
+ adb push -p ~/armnn-devenv/armnn/build/src/backends/backendsCommon/test/testSharedObject/* /data/local/tmp/src/backends/backendsCommon/test/testSharedObject/
+
+ adb shell mkdir -p /data/local/tmp/src/backends/backendsCommon/test/testDynamicBackend
+ adb push -p ~/armnn-devenv/armnn/build/src/backends/backendsCommon/test/testDynamicBackend/* /data/local/tmp/src/backends/backendsCommon/test/testDynamicBackend/
+
+ adb shell mkdir -p /data/local/tmp/src/backends/backendsCommon/test/backendsTestPath1
+ adb push -p ~/armnn-devenv/armnn/build/src/backends/backendsCommon/test/backendsTestPath1/* /data/local/tmp/src/backends/backendsCommon/test/backendsTestPath1/
+
+ adb shell mkdir -p /data/local/tmp/src/backends/backendsCommon/test/backendsTestPath2
+ adb push -p ~/armnn-devenv/armnn/build/src/backends/backendsCommon/test/backendsTestPath2/Arm_CpuAcc_backend.so /data/local/tmp/src/backends/backendsCommon/test/backendsTestPath2/
+ adb shell ln -s Arm_CpuAcc_backend.so /data/local/tmp/src/backends/backendsCommon/test/backendsTestPath2/Arm_CpuAcc_backend.so.1
+ adb shell ln -s Arm_CpuAcc_backend.so.1 /data/local/tmp/src/backends/backendsCommon/test/backendsTestPath2/Arm_CpuAcc_backend.so.1.2
+ adb shell ln -s Arm_CpuAcc_backend.so.1.2 /data/local/tmp/src/backends/backendsCommon/test/backendsTestPath2/Arm_CpuAcc_backend.so.1.2.3
+ adb push -p ~/armnn-devenv/armnn/build/src/backends/backendsCommon/test/backendsTestPath2/Arm_GpuAcc_backend.so /data/local/tmp/src/backends/backendsCommon/test/backendsTestPath2/
+ adb shell ln -s nothing /data/local/tmp/src/backends/backendsCommon/test/backendsTestPath2/Arm_no_backend.so
+
+ adb shell mkdir -p /data/local/tmp/src/backends/backendsCommon/test/backendsTestPath3
+
+ adb shell mkdir -p /data/local/tmp/src/backends/backendsCommon/test/backendsTestPath5
+ adb push -p ~/armnn-devenv/armnn/build/src/backends/backendsCommon/test/backendsTestPath5/* /data/local/tmp/src/backends/backendsCommon/test/backendsTestPath5/
+
+ adb shell mkdir -p /data/local/tmp/src/backends/backendsCommon/test/backendsTestPath6
+ adb push -p ~/armnn-devenv/armnn/build/src/backends/backendsCommon/test/backendsTestPath6/* /data/local/tmp/src/backends/backendsCommon/test/backendsTestPath6/
+
+ adb shell mkdir -p /data/local/tmp/src/backends/backendsCommon/test/backendsTestPath7
+
+ adb shell mkdir -p /data/local/tmp/src/backends/backendsCommon/test/backendsTestPath9
+ adb push -p ~/armnn-devenv/armnn/build/src/backends/backendsCommon/test/backendsTestPath9/* /data/local/tmp/src/backends/backendsCommon/test/backendsTestPath9/
+
+ adb shell mkdir -p /data/local/tmp/src/backends/dynamic/reference
+ adb push -p ~/armnn-devenv/armnn/build/src/backends/dynamic/reference/Arm_CpuRef_backend.so /data/local/tmp/src/backends/dynamic/reference/
+ ```
+
+ If the standalone sample dynamic tests are enabled, also push libArm_SampleDynamic_backend.so library file to the folder specified as $SAMPLE_DYNAMIC_BACKEND_PATH when ArmNN is built.
+ This is the example when $SAMPLE_DYNAMIC_BACKEND_PATH is specified as /data/local/tmp/dynamic/sample/:
+
+ ```bash
+ adb shell mkdir -p /data/local/tmp/dynamic/sample/
+ adb push -p ${WORKING_DIR}/armnn/src/dynamic/sample/build/libArm_SampleDynamic_backend.so /data/local/tmp/dynamic/sample/
+ ```
+
* Run ArmNN unit tests:
```bash
- adb shell 'LD_LIBRARY_PATH=/data/local/tmp /data/local/tmp/UnitTests'
+ adb shell 'LD_LIBRARY_PATH=/data/local/tmp:/vendor/lib64:/vendor/lib64/egl /data/local/tmp/UnitTests'
```
If libarmnnUtils.a is present in `~/armnn-devenv/armnn/build/` and the unit tests run without failure then the build was successful.
-