Skip to content

Commit b167f04

Browse files
digantdesaifacebook-github-bot
authored andcommitted
Minor Script Updates (#715)
Summary: Pull Request resolved: #715 Reviewed By: mcr229 Differential Revision: D50096140 Pulled By: digantdesai fbshipit-source-id: 82d48bc605a248d07d433b696674d432c92fe636
1 parent e15f002 commit b167f04

File tree

3 files changed

+68
-53
lines changed

3 files changed

+68
-53
lines changed

examples/arm/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ run.sh also takes a second optional positional arg to specify a buck2 command.
2323
To run these scripts. On a Linux system, in a terminal, with a working internet connection,
2424
```
2525
# Step [1] - setup necessary tools
26-
$ ./setup.sh
26+
$ ./setup.sh --i-agree-to-the-contained-eula [optional-scratch-dir]
2727
2828
# Step [2] - build + run ExecuTorch and executor_runner baremetal application
2929
# suited for Corstone300 to run a simple PyTorch model.
30-
$ ./run.sh
30+
$ ./run.sh [same-optional-scratch-dir-as-before]
3131
```

examples/arm/run.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77

88
set -eu
99

10-
if [[ "${1:-"."}" == "-h" ]]; then
10+
if [[ "${1:-'.'}" == "-h" || "${#}" -gt 2 ]]; then
1111
echo "Usage: $(basename $0) [path-to-a-scratch-dir] [buck2 binary]"
12-
exit 0
12+
echo "Supplied args: $*"
13+
exit 1
1314
fi
1415

1516
########
@@ -47,8 +48,8 @@ function generate_pte_file() {
4748
# Generate the ethos delegate PTE file
4849
function generate_ethos_pte_file() {
4950
cd $et_root_dir
50-
python3 examples/arm/arm_ethosu_minimal.py &> /dev/null
51-
cd ./ethosout/simple_add/torch/
51+
python3 examples/arm/arm_ethosu_minimal.py &> /dev/null
52+
cd ./ethosout/simple_add/torch/
5253
local pte_file=$(realpath ./delegated.pte)
5354
[[ -f ${pte_file} ]] || { echo "Failed to generate a pte file - ${pte_file}"; exit 1; }
5455
echo "${pte_file}"
@@ -67,6 +68,7 @@ function build_executorch() {
6768
-DEXECUTORCH_BUILD_GFLAGS=OFF \
6869
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=OFF \
6970
-DEXECUTORCH_BUILD_HOST_TARGETS=OFF \
71+
-DEXECUTORCH_BUILD_SDK=OFF \
7072
-DEXECUTORCH_BUILD_ARM_BAREMETAL=ON \
7173
-DCMAKE_BUILD_TYPE=Release \
7274
-DEXECUTORCH_ENABLE_LOGGING=ON \
@@ -78,13 +80,14 @@ function build_executorch() {
7880
echo "[${FUNCNAME[0]}] Configured CMAKE"
7981

8082
n=$(nproc)
81-
cmake --build . -j"$((n - 5))" -- VERBOSE=1
83+
cmake --build . -- -j"$((n - 5))"
8284
echo "[${FUNCNAME[0]}] Generated static libraries for ExecuTorch:"
8385
find . -name "*.a" -exec ls -al {} \;
8486
}
8587

8688
# build Arm Baremetal executor_runner
8789
function build_executorch_runner() {
90+
echo "[${FUNCNAME[0]}] Generating ExecuTorch libraries"
8891
[[ $# -ne 2 ]] && { echo "[${FUNCNAME[0]}]" "Expecting 2 pte files as arguments got, $*"; exit 1; }
8992
local pte=${1}
9093
local pte_delegate=${2}
@@ -100,7 +103,7 @@ function build_executorch_runner() {
100103
echo "[${FUNCNAME[0]}] Configured CMAKE"
101104

102105
n=$(nproc)
103-
cmake --build build -- -j"$((n - 5))" executor_runner executor_runner_delegate VERBOSE=1
106+
cmake --build build -- -j"$((n - 5))" executor_runner executor_runner_delegate
104107
echo "[${FUNCNAME[0]}] Generated baremetal elf file:"
105108
find . -name "executor_runner.elf"
106109
}

examples/arm/setup.sh

Lines changed: 57 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77

88
set -eu
99

10-
if [[ "${1:-'.'}" == "-h" ]]; then
11-
echo "Usage: $(basename $0) [path-to-a-scratch-dir]"
12-
exit 0
10+
if [[ "${1:-'.'}" == "-h" || "${#}" -eq 0 || "${#}" -gt 2 ]]; then
11+
echo "Usage: $(basename $0) <--i-agree-to-the-contained-eula> [path-to-a-scratch-dir]"
12+
echo "Supplied args: $*"
13+
exit 1
1314
fi
1415

1516
########
@@ -44,33 +45,42 @@ function verify_md5() {
4445
script_dir=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
4546

4647
if [[ $(get_cpu_arch) == "x86_64" ]]; then
47-
# FVP
48-
fvp_url="https://developer.arm.com/-/media/Arm%20Developer%20Community/Downloads/OSS/FVP/Corstone-300/FVP_Corstone_SSE-300_11.22_20_Linux64.tgz?rev=018659bd574f4e7b95fa647e7836ccf4&hash=22A79103C6FA5FFA7AFF3BE0447F3FF9"
49-
fvp_model_dir="Linux64_GCC-9.3"
50-
fvp_md5_checksum="98e93b949d0fbac977292d8668d34523"
51-
52-
# toochain
53-
toolchain_url="https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu/12.3.rel1/binrel/arm-gnu-toolchain-12.3.rel1-x86_64-arm-none-eabi.tar.xz"
54-
toolchain_dir="arm-gnu-toolchain-12.3.rel1-x86_64-arm-none-eabi"
55-
toolchain_md5_checksum="00ebb1b70b1f88906c61206457eacb61"
48+
# FVP
49+
fvp_url="https://developer.arm.com/-/media/Arm%20Developer%20Community/Downloads/OSS/FVP/Corstone-300/FVP_Corstone_SSE-300_11.22_20_Linux64.tgz?rev=018659bd574f4e7b95fa647e7836ccf4&hash=22A79103C6FA5FFA7AFF3BE0447F3FF9"
50+
fvp_model_dir="Linux64_GCC-9.3"
51+
fvp_md5_checksum="98e93b949d0fbac977292d8668d34523"
52+
53+
# toochain
54+
toolchain_url="https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu/12.3.rel1/binrel/arm-gnu-toolchain-12.3.rel1-x86_64-arm-none-eabi.tar.xz"
55+
toolchain_dir="arm-gnu-toolchain-12.3.rel1-x86_64-arm-none-eabi"
56+
toolchain_md5_checksum="00ebb1b70b1f88906c61206457eacb61"
5657
elif [[ $(get_cpu_arch) == "aarch64" ]]; then
5758
# FVP
58-
fvp_url="https://developer.arm.com/-/media/Arm%20Developer%20Community/Downloads/OSS/FVP/Corstone-300/FVP_Corstone_SSE-300_11.22_20_Linux64_armv8l.tgz?rev=9cc6e9a32bb947ca9b21fa162144cb01&hash=7657A4CF27D42E892E3F08D452AAB073"
59+
fvp_url="https://developer.arm.com/-/media/Arm%20Developer%20Community/Downloads/OSS/FVP/Corstone-300/FVP_Corstone_SSE-300_11.22_20_Linux64_armv8l.tgz?rev=9cc6e9a32bb947ca9b21fa162144cb01&hash=7657A4CF27D42E892E3F08D452AAB073"
5960
fvp_model_dir="Linux64_armv8l_GCC-9.3"
60-
fvp_md5_checksum="cbbabbe39b07939cff7a3738e1492ef1"
61+
fvp_md5_checksum="cbbabbe39b07939cff7a3738e1492ef1"
6162

6263
# toochain
6364
toolchain_url="https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu/12.3.rel1/binrel/arm-gnu-toolchain-12.3.rel1-aarch64-arm-none-eabi.tar.xz"
6465
toolchain_dir="arm-gnu-toolchain-12.3.rel1-aarch64-arm-none-eabi"
65-
toolchain_md5_checksum="02c9b0d3bb1110575877d8eee1f223f2"
66+
toolchain_md5_checksum="02c9b0d3bb1110575877d8eee1f223f2"
6667
else
67-
echo "[main] Error: only x86-64 & aarch64 architecture is supported for now!"; exit 1;
68+
echo "[main] Error: only x86-64 & aarch64 architecture is supported for now!"; exit 1;
6869
fi
6970

7071
# ethos-u
7172
ethos_u_repo_url="https://review.mlplatform.org/ml/ethos-u/ethos-u"
7273
ethos_u_base_rev="0995223100e3da8011700f58e491f1bf59511e3c"
7374

75+
########
76+
### Mandatory user args
77+
########
78+
eula_acceptance="${1:-'.'}"; shift
79+
if [[ "${eula_acceptance}" != "--i-agree-to-the-contained-eula" ]]; then
80+
echo "Must pass first positional argument '--i-agree-to-the-contained-eula' to agree to EULA associated with downloading the FVP. Exiting!"
81+
exit 1
82+
fi
83+
7484
########
7585
### Optional user args
7686
########
@@ -152,38 +162,40 @@ function patch_repo() {
152162
}
153163

154164
function setup_tosa_reference_model() {
155-
# The debug flow on the host includes running on a reference implementation of TOSA
156-
# This is useful primarily for debug of quantization accuracy, but also for internal
157-
# errors for the early codebase
158-
cd "${root_dir}"
159-
if [[ ! -e reference_model ]]; then
160-
git clone https://git.mlplatform.org/tosa/reference_model.git -b v0.80.0
161-
cd reference_model
162-
git submodule update --init --recursive
163-
cd ..
164-
fi
165-
cd reference_model
166-
mkdir -p build
167-
cd build
168-
cmake ..
169-
make
170-
cd reference_model
171-
tosa_bin_path=`pwd`
172-
echo "export PATH=\${PATH}:${tosa_bin_path}" >> "${setup_path_script}"
165+
# The debug flow on the host includes running on a reference implementation of TOSA
166+
# This is useful primarily for debug of quantization accuracy, but also for internal
167+
# errors for the early codebase
168+
cd "${root_dir}"
169+
if [[ ! -e reference_model ]]; then
170+
git clone https://git.mlplatform.org/tosa/reference_model.git -b v0.80.0
171+
cd reference_model
172+
git submodule update --init --recursive
173+
cd ..
174+
fi
175+
cd reference_model
176+
mkdir -p build
177+
cd build
178+
cmake ..
179+
n=$(nproc)
180+
make -j"$((n - 5))"
181+
cd reference_model
182+
tosa_bin_path=`pwd`
183+
echo "export PATH=\${PATH}:${tosa_bin_path}" >> "${setup_path_script}"
173184
}
174185

175186
function setup_vela() {
176-
#
177-
# Prepare the Vela compiler for AoT to Ethos-U compilation
178-
#
179-
cd "${root_dir}/ethos-u/"
180-
if [[ ! -e ethos-u-vela ]]; then
181-
git clone https://git.mlplatform.org/ml/ethos-u/ethos-u-vela.git
182-
name="ethos-u-vela"
183-
base_rev=00a15db3e1a188b25065d095152d701f4394cdc5
184-
patch_repo
185-
fi
186-
pip install .
187+
#
188+
# Prepare the Vela compiler for AoT to Ethos-U compilation
189+
#
190+
cd "${root_dir}/ethos-u/"
191+
if [[ ! -e ethos-u-vela ]]; then
192+
git clone https://git.mlplatform.org/ml/ethos-u/ethos-u-vela.git
193+
name="ethos-u-vela"
194+
base_rev=00a15db3e1a188b25065d095152d701f4394cdc5
195+
patch_repo
196+
fi
197+
cd "${root_dir}/ethos-u/ethos-u-vela"
198+
pip install .
187199
}
188200

189201
########

0 commit comments

Comments
 (0)