blob: 0788cd5f9581c75db91911857300157f417729f1 [file] [log] [blame]
jimfly0134d6dd72018-11-15 15:46:11 +00001#!/bin/bash
2#
3# Copyright © 2017 Arm Ltd. All rights reserved.
4# SPDX-License-Identifier: MIT
5#
6
James Conroy04cd6032022-04-20 17:16:50 +01007CMD=$( basename "$0" )
jimfly0134d6dd72018-11-15 15:46:11 +00008
Francis Murtagh842e0db2020-01-09 14:24:11 +00009# For pinning to a ref use this:
Nikhil Raj30061c52022-08-29 09:37:57 +010010#DEFAULT_CLFRAMEWORKREVISION="branches/arm_compute_22_08" # Release 22.08
Jim Flynn82fbe7c2019-04-02 15:19:08 +010011#
12# For pinning to a revision use this:
James Conroyae14eba2022-08-30 12:23:11 +010013DEFAULT_CLFRAMEWORKREVISION="552fe4c67d3cd2994cdbd5662cde79da5caf0c4d" #F16 Specialization for MeanStdDevNorm
Jim Flynn82fbe7c2019-04-02 15:19:08 +010014
jimfly0134d6dd72018-11-15 15:46:11 +000015usage() {
James Conroyae14eba2022-08-30 12:23:11 +010016 echo -e "get_compute_library.sh: Clones the Arm Compute Library (ACL) repo from the ML Platform server and checks out
17 the pinned version of ACL based on the SHA string defined at the top of this script (DEFAULT_CLFRAMEWORKREVISION).
18 If the ACL repo already exists, this script will skip cloning and only checkout the relevant SHA.
19 The pinned ACL version is a known version that works correctly with the version of Arm NN being used. This pin is
20 regularly updated by the Arm NN team on the Arm NN 'main' branch.
21 During release periods, the ACL pin will point to an ACL release branch which exists on the ML Platform server.
22 The repo directory will be named 'clframework' unless defined by the '-n' argument to this script.\n"
23 echo "Usage: $CMD (Use the default clframework SHA)"
24 echo "Usage: $CMD -s <CLFRAMEWORK_SHA>"
25 echo "Usage: $CMD -p (Print current default clframework SHA)"
26 echo "Usage: $CMD -n Name of the directory into which the ACL repo will be cloned, default is 'clframework'"
Jim Flynn774f6f12019-04-11 13:10:46 +010027 exit 0
jimfly0134d6dd72018-11-15 15:46:11 +000028}
29
Jim Flynn82fbe7c2019-04-02 15:19:08 +010030PrintDefaultClframeworkSha() {
31 echo $DEFAULT_CLFRAMEWORKREVISION
Jim Flynn774f6f12019-04-11 13:10:46 +010032 exit 0;
Jim Flynn82fbe7c2019-04-02 15:19:08 +010033}
34
jimfly0134d6dd72018-11-15 15:46:11 +000035function AssertZeroExitCode {
36 EXITCODE=$?
37 if [ $EXITCODE -ne 0 ]; then
38 echo "$1"
39 echo "+++ Command exited with code $EXITCODE. Please fix the above errors and re-run"
40 exit 1
41 fi
42}
43
44# process the options given
James Conroyae14eba2022-08-30 12:23:11 +010045while getopts "s:n:ph" opt; do
jimfly0134d6dd72018-11-15 15:46:11 +000046 case "$opt" in
Jim Flynn82fbe7c2019-04-02 15:19:08 +010047 s) CLFRAMEWORK_SHA="$OPTARG";;
48 p) PrintDefaultClframeworkSha;;
James Conroyae14eba2022-08-30 12:23:11 +010049 n) ACL_REPO_NAME_OPTION="$OPTARG";;
jimfly0134d6dd72018-11-15 15:46:11 +000050 h|\?) usage;;
51 esac
52done
53shift $((OPTIND - 1))
54
55#
56# This script is designed to be called from anywhere
57# so it will resolve where to checkout out the clframework
58# relative to its own location in armnn/scripts
59#
60SRC="${BASH_SOURCE[0]}"
61# resolve $SRC until it is no longer a symlink
62while [ -h "$SRC" ]; do
63 DIR="$( cd -P "$( dirname "$SRC" )" >/dev/null && pwd )"
64 SRC="$(readlink "$SRC")"
65 # if $SRC was a relative symlink, we need to resolve it
66 # relative to the path where the symlink file originally was
67 [[ $SRC != /* ]] && SRC="$DIR/$SRC"
68done
69DIR="$( cd -P "$( dirname "$SRC" )" >/dev/null && pwd )"
James Conroy04cd6032022-04-20 17:16:50 +010070pushd "${DIR}" > /dev/null
71# shellcheck disable=SC2164
jimfly0134d6dd72018-11-15 15:46:11 +000072cd ../..
jimfly0134d6dd72018-11-15 15:46:11 +000073
James Conroyae14eba2022-08-30 12:23:11 +010074# Default ACL repo directory name is 'clframework'
75# This can be overwritten by command line option '-n'
76ACL_REPO_NAMFE="clframework"
77if [ ! -z "$ACL_REPO_NAME_OPTION" ]; then
78 ACL_REPO_NAME="$ACL_REPO_NAME_OPTION"
79fi
80
81if [ ! -d "$ACL_REPO_NAME" ]; then
82 echo "Cloning CL Framework"
83 git clone https://review.mlplatform.org/ml/ComputeLibrary "$ACL_REPO_NAME"
jimfly0134d6dd72018-11-15 15:46:11 +000084 AssertZeroExitCode "Cloning CL Framework failed"
85fi
James Conroyae14eba2022-08-30 12:23:11 +010086pushd "$ACL_REPO_NAME" > /dev/null
jimfly0134d6dd72018-11-15 15:46:11 +000087
Jim Flynn82fbe7c2019-04-02 15:19:08 +010088CLFRAMEWORKREVISION=$DEFAULT_CLFRAMEWORKREVISION
89if [ ! -z "$CLFRAMEWORK_SHA" ]; then
James Conroyae14eba2022-08-30 12:23:11 +010090 CLFRAMEWORKREVISION=$CLFRAMEWORK_SHA
Jim Flynn82fbe7c2019-04-02 15:19:08 +010091fi
jimfly0134d6dd72018-11-15 15:46:11 +000092
James Conroyae14eba2022-08-30 12:23:11 +010093echo "git fetch && git fetch https://review.mlplatform.org/ml/ComputeLibrary && git checkout $CLFRAMEWORKREVISION"
James Conroy04cd6032022-04-20 17:16:50 +010094git fetch && git fetch https://review.mlplatform.org/ml/ComputeLibrary && git checkout "${CLFRAMEWORKREVISION}"
Jim Flynn82fbe7c2019-04-02 15:19:08 +010095AssertZeroExitCode "Fetching and checking out ${CLFRAMEWORKREVISION} failed"
Colm Donelan5ed3bc52021-08-19 11:26:04 +010096# If the target ACL revision includes a branch we also need to do a pull.
97# This generally occurs with a release branch.
98if [[ "${CLFRAMEWORKREVISION}" == *"branches"* ]]; then
James Conroyae14eba2022-08-30 12:23:11 +010099 git pull
100 AssertZeroExitCode "ACL reference includes a branch but git pull failed."
Colm Donelan5ed3bc52021-08-19 11:26:04 +0100101fi
jimfly0134d6dd72018-11-15 15:46:11 +0000102
103# Set commit hook so we can submit reviews to gerrit
James Conroy04cd6032022-04-20 17:16:50 +0100104# shellcheck disable=SC2006
105(curl -Lo "$(git rev-parse --git-dir)"/hooks/commit-msg https://review.mlplatform.org/tools/hooks/commit-msg; chmod +x "$(git rev-parse --git-dir)"/hooks/commit-msg)
Jim Flynn82fbe7c2019-04-02 15:19:08 +0100106AssertZeroExitCode "Setting commit hooks failed"
jimfly0134d6dd72018-11-15 15:46:11 +0000107
James Conroyae14eba2022-08-30 12:23:11 +0100108popd > /dev/null # out of clframework / "$ACL_REPO_NAME"
jimfly0134d6dd72018-11-15 15:46:11 +0000109popd > /dev/null # back to wherever we were when called
Jim Flynn82fbe7c2019-04-02 15:19:08 +0100110# Make sure the SHA of the revision that was checked out is the last line
111# of output from the script... just in case we ever need it.
James Conroy04cd6032022-04-20 17:16:50 +0100112echo "$CLFRAMEWORKREVISION"
jimfly0134d6dd72018-11-15 15:46:11 +0000113exit 0