From 542c848730b9d96c3131cba25b3494022011e58f Mon Sep 17 00:00:00 2001 From: Nikhil Raj Date: Wed, 26 Apr 2023 16:22:10 +0100 Subject: IVGCVSW-7536 Update Build Tool for Opaque Delegate Signed-off-by: Nikhil Raj Change-Id: Iaf3f1b5e4e41d0d946a21504c6d44e47d83273e0 --- build-tool/README.md | 62 ++++++++++++++++++++------------------- build-tool/scripts/build-armnn.sh | 62 +++++++++++++++++++++++---------------- build-tool/scripts/setup-armnn.sh | 51 +++++++++++++++++++------------- build-tool/scripts/validation.sh | 2 +- 4 files changed, 99 insertions(+), 78 deletions(-) diff --git a/build-tool/README.md b/build-tool/README.md index 34c8998569..55c2455c13 100644 --- a/build-tool/README.md +++ b/build-tool/README.md @@ -134,22 +134,23 @@ For ease of use (but longer initial docker build), use ```--all``` to have all A Repeated docker builds with the same ```SETUP_ARGS``` will skip the setup process (using [caching](https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#leverage-build-cache) of previous Docker build steps). The ```SETUP_ARGS``` string should start and end with **double quotes** ```"```. -| SETUP_ARGS | Description | -|-------------------|:---------------------------------------------------------------------------------| -| --tflite-delegate | **flag:** setup dependencies for the Arm NN TF Lite Delegate | -| --tflite-parser | **flag:** setup dependencies for the Arm NN TF Lite Parser | -| --onnx-parser | **flag:** setup dependencies for the Arm NN ONNX parser | -| --all | **flag:** setup dependencies for all Arm NN components listed above | -| --target-arch= | **mandatory option:** specify a target architecture ```aarch64, x86_64``` | +| SETUP_ARGS | Description | +|----------------------------|:--------------------------------------------------------------------------| +| --tflite-classic-delegate | **flag:** setup dependencies for the existing Arm NN TF Lite Delegate | +| --tflite-opaque-delegate | **flag:** setup dependencies for the new Arm NN Opaque Delegate | +| --tflite-parser | **flag:** setup dependencies for the Arm NN TF Lite Parser | +| --onnx-parser | **flag:** setup dependencies for the Arm NN ONNX parser | +| --all | **flag:** setup dependencies for all Arm NN components listed above | +| --target-arch= | **mandatory option:** specify a target architecture ```aarch64, x86_64``` | -**At least one component** (e.g. ```--tflite-delegate```) must be provided **or** else provide ```--all``` to setup dependencies for all components. +**At least one component** (e.g. ```--tflite-classic-delegate```) must be provided **or** else provide ```--all``` to setup dependencies for all components. **Examples:**
Setup for aarch64 with all Arm NN dependencies:
```SETUP_ARGS="--target-arch=aarch64 --all"``` -Setup for aarch64 with TF Lite Delegate and TF Lite Parser dependencies only:
-```SETUP_ARGS="--target-arch=aarch64 --tflite-delegate --tflite-parser"``` +Setup for aarch64 with the existing TF Lite Delegate and TF Lite Parser dependencies only:
+```SETUP_ARGS="--target-arch=aarch64 --tflite-classic-delegate --tflite-parser"```
@@ -157,22 +158,23 @@ Setup for aarch64 with TF Lite Delegate and TF Lite Parser dependencies only:
**Should be used for verification purposes only.
Does not provide any performance acceleration.** | -| --debug | **flag:** build Arm NN (and ACL) with debug turned on (optional: defaults to off) | -| --armnn-cmake-args= | **option:** provide additional comma-separated CMake arguments string for building Arm NN (optional)
String should start and end with **single quotes** ```'```
Please refer to **armnn/cmake/GlobalConfig.cmake** | -| --acl-scons-params= | **option**: provide additional comma-separated scons parameters string for building ACL (optional)
String should start and end with **single quotes** ```'```
ACL provide [documentation](https://arm-software.github.io/ComputeLibrary/latest/how_to_build.xhtml#S1_1_build_options) for their build options | - - -**At least one component** (i.e. ```--tflite-delegate```, ```--tflite-parser```, ```--onnx-parser```) must be provided or else provide ```--all``` to build all Arm NN components.
+| BUILD_ARGS | Description | +|---------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| --tflite-classic-delegate | **flag:** build the existing Arm NN TF Lite Delegate component | +| --tflite-opaque-delegate | **flag:** build the new Arm NN Opaque Delegate | +| --tflite-parser | **flag:** build the Arm NN TF Lite Parser component | +| --onnx-parser | **flag:** build the Arm NN ONNX parser component | +| --all | **flag:** build all Arm NN components listed above | +| --target-arch= | **mandatory option:** specify a target architecture ```aarch64, x86_64``` | +| --neon-backend | **flag:** build Arm NN with the NEON backend (CPU acceleration from ACL) | +| --cl-backend | **flag:** build Arm NN with the OpenCL backend (GPU acceleration from ACL) | +| --ref-backend | **flag:** build Arm NN with the reference backend
**Should be used for verification purposes only.
Does not provide any performance acceleration.** | +| --debug | **flag:** build Arm NN (and ACL) with debug turned on (optional: defaults to off) | +| --armnn-cmake-args= | **option:** provide additional comma-separated CMake arguments string for building Arm NN (optional)
String should start and end with **single quotes** ```'```
Please refer to **armnn/cmake/GlobalConfig.cmake** | +| --acl-scons-params= | **option**: provide additional comma-separated scons parameters string for building ACL (optional)
String should start and end with **single quotes** ```'```
ACL provide [documentation](https://arm-software.github.io/ComputeLibrary/latest/how_to_build.xhtml#S1_1_build_options) for their build options | + + +**At least one component** (i.e. ```--tflite-classic-delegate```, ```--tflite-opaque-delegate```, ```--tflite-parser```, ```--onnx-parser```) must be provided or else provide ```--all``` to build all Arm NN components.
**A component given in ```BUILD_ARGS``` must also have been given in ```SETUP_ARGS``` previously**, or else Arm NN will fail to build.
**At least one backend** (i.e. ```--neon-backend```, ```--cl-backend```, ```--ref-backend```) must be chosen.
@@ -180,8 +182,8 @@ The ```BUILD_ARGS``` string should start and end with **double quotes** ```"```. Build for aarch64 with all Arm NN components, NEON enabled and OpenCL enabled:
```BUILD_ARGS="--target-arch=aarch64 --all --neon-backend --cl-backend"``` -Build for aarch64 with TF Lite Delegate, OpenCL enabled and additional ACL scons params:
-```BUILD_ARGS="--target-arch=aarch64 --tflite-delegate --cl-backend --acl-scons-params='compress_kernels=1,benchmark_examples=1'"``` +Build for aarch64 with the existing Arm NN TF Lite Delegate, OpenCL enabled and additional ACL scons params:
+```BUILD_ARGS="--target-arch=aarch64 --tflite-classic-delegate --cl-backend --acl-scons-params='compress_kernels=1,benchmark_examples=1'"``` Setup for aarch64 with all Arm NN dependencies, OpenCL enabled and additional Arm NN cmake args:
```BUILD_ARGS="--target-arch=aarch64 --all --cl-backend --armnn-cmake-args='-DBUILD_SAMPLE_APP=1,-DBUILD_UNIT_TESTS=0'"``` @@ -189,12 +191,12 @@ Setup for aarch64 with all Arm NN dependencies, OpenCL enabled and additional Ar **Example _valid_ combination of SETUP_ARGS and BUILD_ARGS:**
``` SETUP_ARGS="--target-arch=aarch64 --all" -BUILD_ARGS="--target-arch=aarch64 --tflite-delegate --neon-backend --cl-backend" +BUILD_ARGS="--target-arch=aarch64 --tflite-classic-delegate --neon-backend --cl-backend" ``` **Example _invalid_ combination of SETUP_ARGS and BUILD_ARGS:**
``` -SETUP_ARGS="--target-arch=aarch64 --tflite-delegate" +SETUP_ARGS="--target-arch=aarch64 --tflite-classic-delegate" BUILD_ARGS="--target-arch=aarch64 --all --neon-backend --cl-backend" ``` diff --git a/build-tool/scripts/build-armnn.sh b/build-tool/scripts/build-armnn.sh index 61cd36967a..6b5b57d784 100755 --- a/build-tool/scripts/build-armnn.sh +++ b/build-tool/scripts/build-armnn.sh @@ -96,7 +96,8 @@ build_armnn() eval "$compile_flags" \ cmake -DCMAKE_BUILD_TYPE="$build_type" \ - -DBUILD_CLASSIC_DELEGATE="$flag_tflite_delegate" \ + -DBUILD_CLASSIC_DELEGATE="$flag_tflite_classic_delegate" \ + -DBUILD_OPAQUE_DELEGATE="$flag_tflite_opaque_delegate" \ -DBUILD_TF_LITE_PARSER="$flag_tflite_parser" \ -DBUILD_DELEGATE_JNI_INTERFACE="$flag_jni" \ -DBUILD_ONNX_PARSER="$flag_onnx_parser" \ @@ -194,8 +195,10 @@ usage() cat </build-armnn.sh --target-arch=aarch64 --all --neon-backend --cl-backend Build for aarch64 with TF Lite Delegate, OpenCL enabled and additional ACL scons params: - /build-armnn.sh --target-arch=aarch64 --tflite-delegate --cl-backend --acl-scons-params='compress_kernels=1,benchmark_examples=1' + /build-armnn.sh --target-arch=aarch64 --tflite-classic-delegate --cl-backend --acl-scons-params='compress_kernels=1,benchmark_examples=1' Setup for aarch64 with all Arm NN dependencies, OpenCL enabled and additional Arm NN cmake args: /build-armnn.sh --target-arch=aarch64 --all --cl-backend --armnn-cmake-args='-DBUILD_SAMPLE_APP=1,-DBUILD_UNIT_TESTS=0' EOF @@ -249,7 +252,8 @@ EOF target_arch="" # Default flag values -flag_tflite_delegate=0 +flag_tflite_classic_delegate=0 +flag_tflite_opaque_delegate=0 flag_tflite_parser=0 flag_onnx_parser=0 flag_neon_backend=0 @@ -274,7 +278,7 @@ if [ $# -eq 0 ]; then exit 1 fi -args=$(getopt -ohx -l tflite-delegate,tflite-parser,onnx-parser,all,target-arch:,neon-backend,cl-backend,ref-backend,clean,debug,armnn-cmake-args:,acl-scons-params:,num-threads:,help -n "$name" -- "$@") +args=$(getopt -ohx -l tflite-classic-delegate,tflite-opaque-delegate,tflite-parser,onnx-parser,all,target-arch:,neon-backend,cl-backend,ref-backend,clean,debug,armnn-cmake-args:,acl-scons-params:,num-threads:,help -n "$name" -- "$@") eval set -- "$args" while [ $# -gt 0 ]; do if [ -n "${opt_prev:-}" ]; then @@ -295,16 +299,21 @@ while [ $# -gt 0 ]; do flag_tflite_parser=1 ;; - --tflite-delegate) + --tflite-classic-delegate) flag_tflite_delegate=1 ;; + --tflite-opaque-delegate) + flag_tflite_opaque_delegate=1 + ;; + --onnx-parser) flag_onnx_parser=1 ;; --all) - flag_tflite_delegate=1 + flag_tflite_classic_delegate=1 + flag_tflite_opaque_delegate=1 flag_tflite_parser=1 flag_onnx_parser=1 ;; @@ -441,23 +450,24 @@ ARMNN_BUILD_TARGET="$ARMNN_BUILD_ROOT"/"$ARMNN_BUILD_DIR_NAME" ACL_BUILD_TARGET="$BUILD_DIR"/acl/"$TARGET_ARCH"_build"$DEBUG_POSTFIX" echo -e "\nINFO: Displaying configuration information before execution of $name" -echo " target-arch: $TARGET_ARCH" -echo " host-arch: $HOST_ARCH" -echo " tflite-delegate: $flag_tflite_delegate" -echo " tflite-parser: $flag_tflite_parser" -echo " onnx-parser: $flag_onnx_parser" -echo " neon-backend: $flag_neon_backend" -echo " cl-backend: $flag_cl_backend" -echo " ref-backend: $flag_ref_backend" -echo " clean: $flag_clean" -echo " debug: $flag_debug" -echo "armnn-cmake-args: $armnn_cmake_args" -echo "acl-scons-params: $acl_scons_params" -echo " num-threads: $NUM_THREADS" -echo " root directory: $ROOT_DIR" -echo "source directory: $SOURCE_DIR" -echo " build directory: $BUILD_DIR" -echo " armnn build dir: $ARMNN_BUILD_TARGET" +echo " target-arch: $TARGET_ARCH" +echo " host-arch: $HOST_ARCH" +echo "tflite-classic-delegate: $flag_tflite_classic_delegate" +echo "tflite-opaque-delegate : $flag_tflite_opaque_delegate" +echo " tflite-parser: $flag_tflite_parser" +echo " onnx-parser: $flag_onnx_parser" +echo " neon-backend: $flag_neon_backend" +echo " cl-backend: $flag_cl_backend" +echo " ref-backend: $flag_ref_backend" +echo " clean: $flag_clean" +echo " debug: $flag_debug" +echo " armnn-cmake-args: $armnn_cmake_args" +echo " acl-scons-params: $acl_scons_params" +echo " num-threads: $NUM_THREADS" +echo " root directory: $ROOT_DIR" +echo " source directory: $SOURCE_DIR" +echo " build directory: $BUILD_DIR" +echo " armnn build dir: $ARMNN_BUILD_TARGET" echo -e "\nScript execution will begin in 10 seconds..." sleep 10 diff --git a/build-tool/scripts/setup-armnn.sh b/build-tool/scripts/setup-armnn.sh index 9a398d5a46..156bb2fb95 100755 --- a/build-tool/scripts/setup-armnn.sh +++ b/build-tool/scripts/setup-armnn.sh @@ -215,8 +215,10 @@ usage() cat </setup-armnn.sh --target-arch=aarch64 --all -Setup for aarch64 with TF Lite Delegate and TF Lite Parser dependencies only: - /setup-armnn.sh --target-arch=aarch64 --tflite-delegate --tflite-parser +Setup for aarch64 with the existing TF Lite Delegate and TF Lite Parser dependencies only: + /setup-armnn.sh --target-arch=aarch64 --tflite-classic-delegate --tflite-parser EOF } @@ -248,7 +250,8 @@ EOF target_arch="" # Default flag values -flag_tflite_delegate=0 +flag_tflite_classic_delegate=0 +flag_tflite_opaque_delegate=0 flag_tflite_parser=0 flag_onnx_parser=0 @@ -263,7 +266,7 @@ if [ $# -eq 0 ]; then exit 1 fi -args=$(getopt -ohx -l tflite-delegate,tflite-parser,onnx-parser,all,target-arch:,num-threads:,help -n "$name" -- "$@") +args=$(getopt -ohx -l tflite-classic-delegate,tflite-opaque-delegate,tflite-parser,onnx-parser,all,target-arch:,num-threads:,help -n "$name" -- "$@") eval set -- "$args" while [ $# -gt 0 ]; do if [ -n "${opt_prev:-}" ]; then @@ -284,8 +287,12 @@ while [ $# -gt 0 ]; do flag_tflite_parser=1 ;; - --tflite-delegate) - flag_tflite_delegate=1 + --tflite-classic-delegate) + flag_tflite_classic_delegate=1 + ;; + + --tflite-opaque-delegate) + flag_tflite_opaque_delegate=1 ;; --onnx-parser) @@ -293,7 +300,8 @@ while [ $# -gt 0 ]; do ;; --all) - flag_tflite_delegate=1 + flag_tflite_classic_delegate=1 + flag_tflite_opaque_delegate=1 flag_tflite_parser=1 flag_onnx_parser=1 ;; @@ -328,15 +336,16 @@ done source "$rel_path"/common.sh echo -e "\nINFO: Displaying configuration information before execution of $name" -echo " target-arch: $TARGET_ARCH" -echo " host-arch: $HOST_ARCH" -echo " tflite-delegate: $flag_tflite_delegate" -echo " tflite-parser: $flag_tflite_parser" -echo " onnx-parser: $flag_onnx_parser" -echo " num-threads: $NUM_THREADS" -echo " root directory: $ROOT_DIR" -echo "source directory: $SOURCE_DIR" -echo " build directory: $BUILD_DIR" +echo " target-arch: $TARGET_ARCH" +echo " host-arch: $HOST_ARCH" +echo "tflite-classic-delegate: $flag_tflite_classic_delegate" +echo "tflite-opaque-delegate : $flag_tflite_opaque_delegate" +echo " tflite-parser: $flag_tflite_parser" +echo " onnx-parser: $flag_onnx_parser" +echo " num-threads: $NUM_THREADS" +echo " root directory: $ROOT_DIR" +echo " source directory: $SOURCE_DIR" +echo " build directory: $BUILD_DIR" if check_if_repository .; then echo -e "\n***** WARNING: Running script inside a git repository. To avoid nested repos, call this script from outside of this repo. *****" @@ -349,7 +358,7 @@ sleep 10 mkdir -p "$SOURCE_DIR" mkdir -p "$BUILD_DIR" -if [ "$flag_tflite_delegate" -eq 1 ] || [ "$flag_tflite_parser" -eq 1 ]; then +if [ "$flag_tflite_classic_delegate" -eq 1 ] || [ "$flag_tflite_opaque_delegate" -eq 1 ] || [ "$flag_tflite_parser" -eq 1 ]; then download_flatbuffers # Host build @@ -367,7 +376,7 @@ if [ "$flag_tflite_parser" -eq 1 ]; then generate_tflite_schema fi -if [ "$flag_tflite_delegate" -eq 1 ]; then +if [ "$flag_tflite_classic_delegate" -eq 1 ] || [ "$flag_tflite_opaque_delegate" -eq 1 ]; then build_tflite fi diff --git a/build-tool/scripts/validation.sh b/build-tool/scripts/validation.sh index 7928952577..12988b6ae8 100755 --- a/build-tool/scripts/validation.sh +++ b/build-tool/scripts/validation.sh @@ -34,7 +34,7 @@ fi # Validation of chosen Arm NN dependencies if [ "$flag_tflite_delegate" -eq 0 ] && [ "$flag_tflite_parser" -eq 0 ] && [ "$flag_onnx_parser" -eq 0 ]; then - echo "$name: at least one of flags --tflite-delegate, --tflite-parser or --onnx-parser must be set (or --all)." + echo "$name: at least one of flags --tflite-classic-delegate, --tflite-opaque-delegate, --tflite-parser or --onnx-parser must be set (or --all)." exit 1 fi -- cgit v1.2.1