aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kelly <mike.kelly@arm.com>2021-12-14 15:22:48 +0000
committermike.kelly <mike.kelly@arm.com>2021-12-16 15:59:33 +0000
commit4b887708e12944fe3e8c2b9a404d046cae872452 (patch)
treed547502afce7f5c4dc6000a82fb58a26c8de9933
parent407444cd2afecd25676a3255463d710b574d2311 (diff)
downloadarmnn-4b887708e12944fe3e8c2b9a404d046cae872452.tar.gz
IVGCVSW-6668 Add get_tensorflow.sh script
* Added get_tensorflow.sh a script that downloads the version of TensorFlow that ArmNN has been tested against. Signed-off-by: Mike Kelly <mike.kelly@arm.com> Change-Id: Idf2fa8a4e5d4b83c57983683727ba6292fdfa4bc
-rwxr-xr-xscripts/get_tensorflow.sh92
1 files changed, 92 insertions, 0 deletions
diff --git a/scripts/get_tensorflow.sh b/scripts/get_tensorflow.sh
new file mode 100755
index 0000000000..30e7bc6c3c
--- /dev/null
+++ b/scripts/get_tensorflow.sh
@@ -0,0 +1,92 @@
+#!/bin/bash
+#
+# Copyright © 2021 Arm Ltd and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: MIT
+#
+
+CMD=$( basename $0 )
+
+# Revision or tag that Arm NN has been tested with:
+DEFAULT_TENSORFLOW_REVISION="tags/v2.5.0" # Release 2.5.0 tag
+
+Usage() {
+ echo "Gets the revision or tag of TensorFlow that this version of Arm NN has been"
+ echo "tested with."
+ echo
+ echo "Usage: $CMD Gets the default TensorFlow revision/tag ($DEFAULT_TENSORFLOW_REVISION)"
+ echo "Usage: $CMD -s <TENSORFLOW_SHA>"
+ echo "Usage: $CMD -p (Print current default revision/tag)"
+ exit 0
+}
+
+PrintDefaultTensorFlowSha() {
+ echo $DEFAULT_TENSORFLOW_REVISION
+ exit 0;
+}
+
+function AssertZeroExitCode {
+ EXITCODE=$?
+ if [ $EXITCODE -ne 0 ]; then
+ echo "$1"
+ echo "+++ Command exited with code $EXITCODE. Please fix the above errors and re-run"
+ exit 1
+ fi
+}
+
+# Revision or tag to check out
+TENSORFLOW_REVISION=$DEFAULT_TENSORFLOW_REVISION
+
+# process the options given
+while getopts "s:ph\?:" opt; do
+ case "$opt" in
+ s) TENSORFLOW_REVISION="$OPTARG";;
+ p) PrintDefaultTensorFlowSha;;
+ h|\?) Usage;;
+ esac
+done
+shift $((OPTIND - 1))
+
+#
+# This script is designed to be called from anywhere
+# so it will resolve where to checkout out TensorFlow
+# relative to its own location in armnn/scripts
+#
+SRC="${BASH_SOURCE[0]}"
+# resolve $SRC until it is no longer a symlink
+while [ -h "$SRC" ]; do
+ DIR="$( cd -P "$( dirname "$SRC" )" >/dev/null && pwd )"
+ SRC="$(readlink "$SRC")"
+ # if $SRC was a relative symlink, we need to resolve it
+ # relative to the path where the symlink file originally was
+ [[ $SRC != /* ]] && SRC="$DIR/$SRC"
+done
+DIR="$( cd -P "$( dirname "$SRC" )" >/dev/null && pwd )"
+pushd ${DIR} > /dev/null
+cd ../..
+
+# Clone TensorFlow if we don't already have a directory
+if [ ! -d tensorflow ]; then
+ echo "Cloning TensorFlow"
+ git clone https://github.com/tensorflow/tensorflow.git
+ AssertZeroExitCode "Cloning TensorFlow failed"
+fi
+pushd tensorflow > /dev/null
+
+# Checkout the TensorFlow revision
+echo "Checking out ${TENSORFLOW_REVISION}"
+git fetch && git checkout ${TENSORFLOW_REVISION}
+AssertZeroExitCode "Fetching and checking out ${TENSORFLOW_REVISION} failed"
+# If the target tensorflow revision includes a branch we also need to do a pull.
+# This generally occurs with a release branch.
+if [[ "${TENSORFLOW_REVISION}" == *"branches"* ]]; then
+ git pull
+ AssertZeroExitCode "TensorFlow reference includes a branch but git pull failed."
+fi
+
+popd > /dev/null # out of tensorflow
+popd > /dev/null # back to wherever we were when called
+# Make sure the SHA of the revision that was checked out is the last line
+# of output from the script... just in case we ever need it.
+echo $TENSORFLOW_REVISION
+exit 0