aboutsummaryrefslogtreecommitdiff
path: root/build-tool/scripts/build-armnn.sh
diff options
context:
space:
mode:
authorJames Conroy <james.conroy@arm.com>2022-08-04 16:55:05 +0100
committerNikhil Raj <nikhil.raj@arm.com>2022-08-05 16:33:41 +0100
commit210897d7afb4007fe06d390c2ec333a732390b5c (patch)
treefc172104328e511c3c262135f40cba0f25a96068 /build-tool/scripts/build-armnn.sh
parentdba6773af86ac3f79171503fd3b48b0bd1618239 (diff)
downloadarmnn-210897d7afb4007fe06d390c2ec333a732390b5c.tar.gz
IVGCVSW-6777 Add Arm NN build-tool Dockerfile
* Adds Dockerfile associated with Arm NN build-tool scripts. * The Dockerfile encapsulates the installation of system-wide packages (install-packages.sh), download/install of Arm NN dependencies (setup-armnn.sh) and the building of Arm NN and ACL (build-armnn.sh). * A helper script for copying build contents from the built Docker image is provided for by docker-copy-to-host.sh. * Modified existing scripts: moved the cloning of Arm NN and ACL from setup-armnn.sh to build-armnn.sh and decoupled setup-armnn.sh from scripts outside of build-tool directory e.g. armnn/scripts/get_tensorflow.sh. * The build-armnn.sh script clones the latest release branches of Arm NN and ACL by default. Custom repos can be placed in the build-tool directory prior to 'docker build' and they will be used instead (advanced usage). * Support added for Linux targets only, Android to be added in future work. Signed-off-by: James Conroy <james.conroy@arm.com> Change-Id: I336013cf93821d2cd3e5d9fe2ca4e955ffdd2386
Diffstat (limited to 'build-tool/scripts/build-armnn.sh')
-rwxr-xr-xbuild-tool/scripts/build-armnn.sh61
1 files changed, 52 insertions, 9 deletions
diff --git a/build-tool/scripts/build-armnn.sh b/build-tool/scripts/build-armnn.sh
index 2b8217b313..98b3b3f6fc 100755
--- a/build-tool/scripts/build-armnn.sh
+++ b/build-tool/scripts/build-armnn.sh
@@ -149,6 +149,43 @@ build_armnn()
return 0
}
+download_armnn()
+{
+ cd "$SOURCE_DIR"
+
+ echo -e "\n***** Downloading Arm NN *****"
+
+ rm -rf "$ARMNN_SRC"
+
+ # Latest release branch of Arm NN is checked out by default
+ git clone https://github.com/ARM-software/armnn.git armnn
+
+ cd "$ARMNN_SRC"
+ armnn_branch="$(git rev-parse --abbrev-ref HEAD)"
+
+ echo -e "\n***** Arm NN Downloaded: $armnn_branch *****"
+}
+
+download_acl()
+{
+ cd "$SOURCE_DIR"
+
+ echo -e "\n***** Downloading ACL *****"
+
+ rm -rf "$ACL_SRC"
+
+ git clone https://github.com/ARM-software/ComputeLibrary.git acl
+
+ # Get corresponding release tag for ACL by parsing release branch number for Arm NN
+ local acl_tag=""
+ acl_tag="$(echo "$armnn_branch" | tr '\n' ' ' | sed -e 's/[^0-9]/ /g' -e 's/^ *//g' -e 's/ *$//g' | tr -s ' ' | sed 's/ /./g')"
+
+ cd "$ACL_SRC"
+ git checkout v"$acl_tag"
+
+ echo -e "\n***** ACL Downloaded: $acl_tag *****"
+}
+
usage()
{
cat <<EOF
@@ -189,8 +226,9 @@ At least one component (i.e. --tflite-delegate, --tflite-parser, --onnx-parser)
At least one backend (i.e. --neon-backend, --cl-backend, --ref-backend) must be chosen.
This script must be executed from the same root directory in which setup-armnn.sh was executed from.
-This script will build using Arm NN and ACL repositories checked out in <ROOT_DIR>/source, downloaded using setup-armnn.sh.
+The first execution of this script will download the latest release branches of Arm NN and ACL, by default.
Alternatively, place custom/modified repositories named "armnn" and "acl" in <ROOT_DIR>/source.
+If providing custom repos, both Arm NN and ACL must be provided. The ACL repo will not be used if flags --neon-backend or --cl-backend are not selected.
By default, a tarball tar.gz archive of the Arm NN build will be created in the directory from which this script is called from.
@@ -356,17 +394,22 @@ if [ ! -d "$BUILD_DIR" ]; then
exit 1
fi
-# Verify that Arm NN and ACL exist in correct paths prior to script execution
-if [ ! -d "$ARMNN_SRC" ]; then
- echo -e "\nERROR: Arm NN repo does not exist as expected at $ARMNN_SRC"
- exit 1
-fi
+# Download Arm NN and ACL if not done already in a previous execution of this script
+# Check if Arm NN source directory exists AND that it is a repository (not empty)
+if [ -d "$ARMNN_SRC" ] && check_if_repository "$ARMNN_SRC"; then
+ echo -e "\n***** Arm NN source repository already located at $ARMNN_SRC. Skipping cloning of Arm NN. *****"
-if [ "$flag_neon_backend" -eq 1 ] || [ "$flag_cl_backend" -eq 1 ]; then
- if [ ! -d "$ACL_SRC" ]; then
- echo -e "\nERROR: ACL repo does not exist as expected at $ACL_SRC"
+ # ACL repo must also be present if Arm NN repo is present
+ if [ -d "$ACL_SRC" ] && check_if_repository "$ACL_SRC"; then
+ echo -e "\n***** ACL source repository already located at $ACL_SRC. Skipping cloning of ACL. *****"
+ else
+ echo -e "\nERROR: ACL source repository must be provided at $ACL_SRC if Arm NN source is provided. *****"
exit 1
fi
+else
+ # Download latest release branches of Arm NN and ACL
+ download_armnn
+ download_acl
fi
# Adjust output build directory names for Arm NN and ACL if debug is enabled