From 152c4ff5a911d77a552067bb3916ed84d63cf68d Mon Sep 17 00:00:00 2001 From: Huy Do Date: Tue, 9 Jan 2024 19:31:47 -0800 Subject: [PATCH 1/3] Move arm setup script into .ci/docker and create links to them --- .ci/docker/build.sh | 12 +- .../arm/ethos-u-setup/arm-none-eabi-gcc.cmake | 0 .../patches/0001-Executorch-Add-README.patch | 0 ...-patch-regress-cmake-version-from-3..patch | 0 ...-patch-Disable-warnings-to-reduce-ve.patch | 0 ...cal-patch-New-phdr-for-.data-section.patch | 0 ...-Executorch-Add-pte-to-header-script.patch | 0 ...xecutorch-Add-executorch_runner-test.patch | 0 ...-Executorch-Add-delegate-runner-test.patch | 0 ...-new-LIB_ET_OP_REGISTRATION-lib-path.patch | 0 ...orch-Use-libportable_ops_lib-instead.patch | 0 ...001-Improve-rescale-codegen-for-TOSA.patch | 0 .ci/docker/examples/arm/setup.sh | 246 +++++++++++++++++ .ci/docker/requirements-lintrunner.txt | 22 ++ .ci/docker/ubuntu/Dockerfile | 2 +- examples/arm/ethos-u-setup | 1 + examples/arm/setup.sh | 247 +----------------- requirements-lintrunner.txt | 23 +- 18 files changed, 276 insertions(+), 277 deletions(-) rename {examples => .ci/docker/examples}/arm/ethos-u-setup/arm-none-eabi-gcc.cmake (100%) rename {examples => .ci/docker/examples}/arm/ethos-u-setup/core_platform/patches/0001-Executorch-Add-README.patch (100%) rename {examples => .ci/docker/examples}/arm/ethos-u-setup/core_platform/patches/0002-Executorch-local-patch-regress-cmake-version-from-3..patch (100%) rename {examples => .ci/docker/examples}/arm/ethos-u-setup/core_platform/patches/0003-Executorch-local-patch-Disable-warnings-to-reduce-ve.patch (100%) rename {examples => .ci/docker/examples}/arm/ethos-u-setup/core_platform/patches/0004-Executorch-local-patch-New-phdr-for-.data-section.patch (100%) rename {examples => .ci/docker/examples}/arm/ethos-u-setup/core_platform/patches/0005-Executorch-Add-pte-to-header-script.patch (100%) rename {examples => .ci/docker/examples}/arm/ethos-u-setup/core_platform/patches/0006-Executorch-Add-executorch_runner-test.patch (100%) rename {examples => .ci/docker/examples}/arm/ethos-u-setup/core_platform/patches/0007-Executorch-Add-delegate-runner-test.patch (100%) rename {examples => .ci/docker/examples}/arm/ethos-u-setup/core_platform/patches/0008-Use-new-LIB_ET_OP_REGISTRATION-lib-path.patch (100%) rename {examples => .ci/docker/examples}/arm/ethos-u-setup/core_platform/patches/0009-Executorch-Use-libportable_ops_lib-instead.patch (100%) rename {examples => .ci/docker/examples}/arm/ethos-u-setup/ethos-u-vela/patches/0001-Improve-rescale-codegen-for-TOSA.patch (100%) create mode 100755 .ci/docker/examples/arm/setup.sh create mode 100644 .ci/docker/requirements-lintrunner.txt create mode 120000 examples/arm/ethos-u-setup mode change 100755 => 120000 examples/arm/setup.sh mode change 100644 => 120000 requirements-lintrunner.txt diff --git a/.ci/docker/build.sh b/.ci/docker/build.sh index 6440a3c1d68..e09cdc0ffe5 100755 --- a/.ci/docker/build.sh +++ b/.ci/docker/build.sh @@ -34,17 +34,13 @@ case "${IMAGE_NAME}" in exit 1 esac +# NB: All files needed to build the Docker image needs to be in .ci/docker +# folder so that the image hash is updated correctly when they change. The +# good news is that links can be setup to refer to them from other locations + TORCH_VERSION=$(cat ci_commit_pins/pytorch.txt) BUILD_DOCS=1 -# Copy requirements-lintrunner.txt from root to here -cp ../../requirements-lintrunner.txt ./ - -# Copy arm setup script from root to here -# TODO(huydhn): Figure out a way to rebuild the Docker image automatically -# with a new image hash when the content here is updated -cp -r ../../examples/arm/ ./arm - docker build \ --no-cache \ --progress=plain \ diff --git a/examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake b/.ci/docker/examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake similarity index 100% rename from examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake rename to .ci/docker/examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake diff --git a/examples/arm/ethos-u-setup/core_platform/patches/0001-Executorch-Add-README.patch b/.ci/docker/examples/arm/ethos-u-setup/core_platform/patches/0001-Executorch-Add-README.patch similarity index 100% rename from examples/arm/ethos-u-setup/core_platform/patches/0001-Executorch-Add-README.patch rename to .ci/docker/examples/arm/ethos-u-setup/core_platform/patches/0001-Executorch-Add-README.patch diff --git a/examples/arm/ethos-u-setup/core_platform/patches/0002-Executorch-local-patch-regress-cmake-version-from-3..patch b/.ci/docker/examples/arm/ethos-u-setup/core_platform/patches/0002-Executorch-local-patch-regress-cmake-version-from-3..patch similarity index 100% rename from examples/arm/ethos-u-setup/core_platform/patches/0002-Executorch-local-patch-regress-cmake-version-from-3..patch rename to .ci/docker/examples/arm/ethos-u-setup/core_platform/patches/0002-Executorch-local-patch-regress-cmake-version-from-3..patch diff --git a/examples/arm/ethos-u-setup/core_platform/patches/0003-Executorch-local-patch-Disable-warnings-to-reduce-ve.patch b/.ci/docker/examples/arm/ethos-u-setup/core_platform/patches/0003-Executorch-local-patch-Disable-warnings-to-reduce-ve.patch similarity index 100% rename from examples/arm/ethos-u-setup/core_platform/patches/0003-Executorch-local-patch-Disable-warnings-to-reduce-ve.patch rename to .ci/docker/examples/arm/ethos-u-setup/core_platform/patches/0003-Executorch-local-patch-Disable-warnings-to-reduce-ve.patch diff --git a/examples/arm/ethos-u-setup/core_platform/patches/0004-Executorch-local-patch-New-phdr-for-.data-section.patch b/.ci/docker/examples/arm/ethos-u-setup/core_platform/patches/0004-Executorch-local-patch-New-phdr-for-.data-section.patch similarity index 100% rename from examples/arm/ethos-u-setup/core_platform/patches/0004-Executorch-local-patch-New-phdr-for-.data-section.patch rename to .ci/docker/examples/arm/ethos-u-setup/core_platform/patches/0004-Executorch-local-patch-New-phdr-for-.data-section.patch diff --git a/examples/arm/ethos-u-setup/core_platform/patches/0005-Executorch-Add-pte-to-header-script.patch b/.ci/docker/examples/arm/ethos-u-setup/core_platform/patches/0005-Executorch-Add-pte-to-header-script.patch similarity index 100% rename from examples/arm/ethos-u-setup/core_platform/patches/0005-Executorch-Add-pte-to-header-script.patch rename to .ci/docker/examples/arm/ethos-u-setup/core_platform/patches/0005-Executorch-Add-pte-to-header-script.patch diff --git a/examples/arm/ethos-u-setup/core_platform/patches/0006-Executorch-Add-executorch_runner-test.patch b/.ci/docker/examples/arm/ethos-u-setup/core_platform/patches/0006-Executorch-Add-executorch_runner-test.patch similarity index 100% rename from examples/arm/ethos-u-setup/core_platform/patches/0006-Executorch-Add-executorch_runner-test.patch rename to .ci/docker/examples/arm/ethos-u-setup/core_platform/patches/0006-Executorch-Add-executorch_runner-test.patch diff --git a/examples/arm/ethos-u-setup/core_platform/patches/0007-Executorch-Add-delegate-runner-test.patch b/.ci/docker/examples/arm/ethos-u-setup/core_platform/patches/0007-Executorch-Add-delegate-runner-test.patch similarity index 100% rename from examples/arm/ethos-u-setup/core_platform/patches/0007-Executorch-Add-delegate-runner-test.patch rename to .ci/docker/examples/arm/ethos-u-setup/core_platform/patches/0007-Executorch-Add-delegate-runner-test.patch diff --git a/examples/arm/ethos-u-setup/core_platform/patches/0008-Use-new-LIB_ET_OP_REGISTRATION-lib-path.patch b/.ci/docker/examples/arm/ethos-u-setup/core_platform/patches/0008-Use-new-LIB_ET_OP_REGISTRATION-lib-path.patch similarity index 100% rename from examples/arm/ethos-u-setup/core_platform/patches/0008-Use-new-LIB_ET_OP_REGISTRATION-lib-path.patch rename to .ci/docker/examples/arm/ethos-u-setup/core_platform/patches/0008-Use-new-LIB_ET_OP_REGISTRATION-lib-path.patch diff --git a/examples/arm/ethos-u-setup/core_platform/patches/0009-Executorch-Use-libportable_ops_lib-instead.patch b/.ci/docker/examples/arm/ethos-u-setup/core_platform/patches/0009-Executorch-Use-libportable_ops_lib-instead.patch similarity index 100% rename from examples/arm/ethos-u-setup/core_platform/patches/0009-Executorch-Use-libportable_ops_lib-instead.patch rename to .ci/docker/examples/arm/ethos-u-setup/core_platform/patches/0009-Executorch-Use-libportable_ops_lib-instead.patch diff --git a/examples/arm/ethos-u-setup/ethos-u-vela/patches/0001-Improve-rescale-codegen-for-TOSA.patch b/.ci/docker/examples/arm/ethos-u-setup/ethos-u-vela/patches/0001-Improve-rescale-codegen-for-TOSA.patch similarity index 100% rename from examples/arm/ethos-u-setup/ethos-u-vela/patches/0001-Improve-rescale-codegen-for-TOSA.patch rename to .ci/docker/examples/arm/ethos-u-setup/ethos-u-vela/patches/0001-Improve-rescale-codegen-for-TOSA.patch diff --git a/.ci/docker/examples/arm/setup.sh b/.ci/docker/examples/arm/setup.sh new file mode 100755 index 00000000000..1094e008e55 --- /dev/null +++ b/.ci/docker/examples/arm/setup.sh @@ -0,0 +1,246 @@ +#!/usr/bin/env bash +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. + +set -eu + +if [[ "${1:-'.'}" == "-h" || "${#}" -eq 0 || "${#}" -gt 2 ]]; then + echo "Usage: $(basename $0) <--i-agree-to-the-contained-eula> [path-to-a-scratch-dir]" + echo "Supplied args: $*" + exit 1 +fi + +######## +### Helper functions +######## +function get_os_name() { + # Returns the name of the system i.e. Linux or Darwin + uname -s +} + +function get_cpu_arch() { + # Returns the cpu architecture like arm64 or x86-64 + uname -m +} + +function verify_md5() { + [[ $# -ne 2 ]] \ + && { echo "[${FUNCNAME[0]}] Invalid number of args, expecting 2, but got $#"; exit 1; } + local ref_checksum="${1}" + local file="${2}" + + local file_checksum="$(md5sum $file | awk '{print $1}')" + if [[ ${ref_checksum} != ${file_checksum} ]]; then + echo "Mismatched MD5 checksum for file: ${file}. Expecting ${ref_checksum} but got ${file_checksum}. Exiting." + exit 1 + fi +} + +######## +### Hardcoded constants +######## +script_dir=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) + +if [[ $(get_cpu_arch) == "x86_64" ]]; then + # FVP + 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" + fvp_model_dir="Linux64_GCC-9.3" + fvp_md5_checksum="98e93b949d0fbac977292d8668d34523" + + # toochain + 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" + toolchain_dir="arm-gnu-toolchain-12.3.rel1-x86_64-arm-none-eabi" + toolchain_md5_checksum="00ebb1b70b1f88906c61206457eacb61" +elif [[ $(get_cpu_arch) == "aarch64" ]]; then + # FVP + 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" + fvp_model_dir="Linux64_armv8l_GCC-9.3" + fvp_md5_checksum="cbbabbe39b07939cff7a3738e1492ef1" + + # toochain + 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" + toolchain_dir="arm-gnu-toolchain-12.3.rel1-aarch64-arm-none-eabi" + toolchain_md5_checksum="02c9b0d3bb1110575877d8eee1f223f2" +else + echo "[main] Error: only x86-64 & aarch64 architecture is supported for now!"; exit 1; +fi + +# ethos-u +ethos_u_repo_url="https://review.mlplatform.org/ml/ethos-u/ethos-u" +ethos_u_base_rev="0995223100e3da8011700f58e491f1bf59511e3c" + +######## +### Mandatory user args +######## +eula_acceptance="${1:-'.'}"; shift +if [[ "${eula_acceptance}" != "--i-agree-to-the-contained-eula" ]]; then + echo "Must pass first positional argument '--i-agree-to-the-contained-eula' to agree to EULA associated with downloading the FVP. Exiting!" + exit 1 +fi + +######## +### Optional user args +######## +root_dir=${1:-"${script_dir}/ethos-u-scratch"} +root_dir=$(realpath ${root_dir}) + +######## +### Functions +######## + +function setup_fvp() { + # Download and install the Corstone 300 FVP simulator platform + cd "${root_dir}" + if [[ ! -e FVP_cs300.tgz ]]; then + echo "[${FUNCNAME[0]}] Downloading FVP ..." + curl --output FVP_cs300.tgz "${fvp_url}" + verify_md5 ${fvp_md5_checksum} FVP_cs300.tgz + fi + + echo "[${FUNCNAME[0]}] Installing FVP ..." + rm -rf FVP + mkdir -p FVP + cd FVP + tar xf ../FVP_cs300.tgz + ./FVP_Corstone_SSE-300.sh --i-agree-to-the-contained-eula --force --destination ./ --quiet --no-interactive + + fvp_bin_path="$(cd models/${fvp_model_dir} && pwd)" + export PATH=${PATH}:${fvp_bin_path} + + hash FVP_Corstone_SSE-300_Ethos-U55 + echo "export PATH=\${PATH}:${fvp_bin_path}" >> ${setup_path_script} + +} + +function setup_toolchain() { + # Download and install the arm-none-eabi toolchain + cd "${root_dir}" + if [[ ! -e gcc.tar.xz ]]; then + echo "[${FUNCNAME[0]}] Downloading toolchain ..." + curl --output gcc.tar.xz "${toolchain_url}" + verify_md5 ${toolchain_md5_checksum} gcc.tar.xz + fi + + echo "[${FUNCNAME[0]}] Installing toolchain ..." + rm -rf "${toolchain_dir}" + tar xf gcc.tar.xz + toolchain_bin_path="$(cd ${toolchain_dir}/bin && pwd)" + export PATH=${PATH}:${toolchain_bin_path} + hash arm-none-eabi-gcc + echo "export PATH=\${PATH}:${toolchain_bin_path}" >> ${setup_path_script} +} + +function setup_ethos_u() { + # This is the main dir which will pull more repos to do baremetal software dev for cs300 + echo "[${FUNCNAME[0]}] Setting up the repo" + cd "${root_dir}" + [[ ! -d ethos-u ]] && \ + git clone ${ethos_u_repo_url} + cd ethos-u + git reset --hard ${ethos_u_base_rev} + python3 ./fetch_externals.py fetch + pip install pyelftools + echo "[${FUNCNAME[0]}] Done @ $(git describe --all --long 3> /dev/null) in ${root_dir}/ethos-u dir." +} + +function patch_repo() { + # This is a temporary hack until it finds a better home in one for the ARM Ml repos + name="$(basename $repo_dir)" + echo -e "[${FUNCNAME[0]}] Preparing ${name}..." + cd $repo_dir + + git reset --hard ${base_rev} + + patch_dir=${script_dir}/ethos-u-setup/${name}/patches/ + [[ -e ${patch_dir} && $(ls -A ${patch_dir}) ]] && \ + git am -3 ${patch_dir}/*.patch + + echo -e "[${FUNCNAME[0]}] Patched ${name} @ $(git describe --all --long 2> /dev/null) in ${repo_dir} dir.\n" +} + +function setup_tosa_reference_model() { + # The debug flow on the host includes running on a reference implementation of TOSA + # This is useful primarily for debug of quantization accuracy, but also for internal + # errors for the early codebase + cd "${root_dir}" + if [[ ! -e reference_model ]]; then + git clone https://review.mlplatform.org/tosa/reference_model -b main + cd reference_model + git submodule update --init --recursive + cd .. + fi + cd reference_model + mkdir -p build + cd build + cmake .. + n=$(nproc) + make -j"$((n - 5))" + cd reference_model + tosa_bin_path=`pwd` + echo "export PATH=\${PATH}:${tosa_bin_path}" >> "${setup_path_script}" +} + +function setup_vela() { + # + # Prepare the Vela compiler for AoT to Ethos-U compilation + # + cd "${root_dir}" + if [[ ! -e ethos-u-vela ]]; then + git clone https://review.mlplatform.org/ml/ethos-u/ethos-u-vela + repo_dir="${root_dir}/ethos-u-vela" + base_rev=00a15db3e1a188b25065d095152d701f4394cdc5 + patch_repo + fi + cd "${root_dir}/ethos-u-vela" + pip install . +} + +######## +### main +######## +# do basic checks +# Make sure we are on a supported platform +[[ $(get_cpu_arch) != "x86_64" ]] && [[ $(get_cpu_arch) != "aarch64" ]] \ + && { echo "[main] Error: only x86-64 & aarch64 architecture is supported for now!"; exit 1; } + +# No OSx support for FVP +[[ "$(get_os_name)" != "Linux" ]] \ + && { echo "[main] Error: only Linux os is supported for now!"; exit 1; } + +cd "${script_dir}" + +# Setup the root dir +mkdir -p "${root_dir}" +cd "${root_dir}" +echo "[main] Using root dir ${root_dir}" + +setup_path_script="${root_dir}/setup_path.sh" +echo "" > "${setup_path_script}" + +# Setup FVP +setup_fvp + +# Setup toolchain +setup_toolchain + +# Setup the ethos-u dev environment +setup_ethos_u + +# Patch the ethos-u dev environment to include executorch application +repo_dir="${root_dir}/ethos-u/core_platform" +base_rev=204210b1074071532627da9dc69950d058a809f4 +patch_repo + +# Setup the tosa_reference_model +setup_tosa_reference_model + +# Setup vela and patch in codegen fixes +setup_vela + +echo "[main] update path by doing 'source ${setup_path_script}'" + +echo "[main] success!" +exit 0 diff --git a/.ci/docker/requirements-lintrunner.txt b/.ci/docker/requirements-lintrunner.txt new file mode 100644 index 00000000000..e5caf38c59e --- /dev/null +++ b/.ci/docker/requirements-lintrunner.txt @@ -0,0 +1,22 @@ +# Lintrunner itself +lintrunner==0.11.0 +lintrunner-adapters==0.11.0 + +# Flake 8 and its dependencies +flake8==6.0.0 +flake8-breakpoint==1.1.0 +flake8-bugbear==23.6.5 +flake8-comprehensions==3.12.0 +flake8-pyi==23.5.0 +mccabe==0.7.0 +pycodestyle==2.10.0 +torchfix==0.1.1 + +# UFMT +black==22.12.0 +ufmt==2.0.1 +usort==1.0.5 + +# Other linters +clang-format==12.0.1 +cmakelint==1.4.1 diff --git a/.ci/docker/ubuntu/Dockerfile b/.ci/docker/ubuntu/Dockerfile index 4680fc2ee5c..277f3f9fd3b 100644 --- a/.ci/docker/ubuntu/Dockerfile +++ b/.ci/docker/ubuntu/Dockerfile @@ -67,7 +67,7 @@ RUN if [ -n "${LINTRUNNER}" ]; then bash ./install_linter.sh; fi RUN rm install_linter.sh utils.sh requirements-lintrunner.txt ARG ARM_SDK -COPY --chown=ci-user:ci-user ./arm /opt/arm +COPY --chown=ci-user:ci-user ./examples/arm /opt/arm # Set up ARM SDK if needed RUN if [ -n "${ARM_SDK}" ]; then git config --global user.email "ossci@example.com"; git config --global user.name "OSS CI"; bash /opt/arm/setup.sh --i-agree-to-the-contained-eula /opt/arm-sdk; chown -R ci-user:ci-user /opt/arm-sdk; fi diff --git a/examples/arm/ethos-u-setup b/examples/arm/ethos-u-setup new file mode 120000 index 00000000000..f88ac4458b7 --- /dev/null +++ b/examples/arm/ethos-u-setup @@ -0,0 +1 @@ +../../.ci/docker/examples/arm/ethos-u-setup \ No newline at end of file diff --git a/examples/arm/setup.sh b/examples/arm/setup.sh deleted file mode 100755 index 1094e008e55..00000000000 --- a/examples/arm/setup.sh +++ /dev/null @@ -1,246 +0,0 @@ -#!/usr/bin/env bash -# Copyright (c) Meta Platforms, Inc. and affiliates. -# All rights reserved. -# -# This source code is licensed under the BSD-style license found in the -# LICENSE file in the root directory of this source tree. - -set -eu - -if [[ "${1:-'.'}" == "-h" || "${#}" -eq 0 || "${#}" -gt 2 ]]; then - echo "Usage: $(basename $0) <--i-agree-to-the-contained-eula> [path-to-a-scratch-dir]" - echo "Supplied args: $*" - exit 1 -fi - -######## -### Helper functions -######## -function get_os_name() { - # Returns the name of the system i.e. Linux or Darwin - uname -s -} - -function get_cpu_arch() { - # Returns the cpu architecture like arm64 or x86-64 - uname -m -} - -function verify_md5() { - [[ $# -ne 2 ]] \ - && { echo "[${FUNCNAME[0]}] Invalid number of args, expecting 2, but got $#"; exit 1; } - local ref_checksum="${1}" - local file="${2}" - - local file_checksum="$(md5sum $file | awk '{print $1}')" - if [[ ${ref_checksum} != ${file_checksum} ]]; then - echo "Mismatched MD5 checksum for file: ${file}. Expecting ${ref_checksum} but got ${file_checksum}. Exiting." - exit 1 - fi -} - -######## -### Hardcoded constants -######## -script_dir=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) - -if [[ $(get_cpu_arch) == "x86_64" ]]; then - # FVP - 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" - fvp_model_dir="Linux64_GCC-9.3" - fvp_md5_checksum="98e93b949d0fbac977292d8668d34523" - - # toochain - 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" - toolchain_dir="arm-gnu-toolchain-12.3.rel1-x86_64-arm-none-eabi" - toolchain_md5_checksum="00ebb1b70b1f88906c61206457eacb61" -elif [[ $(get_cpu_arch) == "aarch64" ]]; then - # FVP - 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" - fvp_model_dir="Linux64_armv8l_GCC-9.3" - fvp_md5_checksum="cbbabbe39b07939cff7a3738e1492ef1" - - # toochain - 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" - toolchain_dir="arm-gnu-toolchain-12.3.rel1-aarch64-arm-none-eabi" - toolchain_md5_checksum="02c9b0d3bb1110575877d8eee1f223f2" -else - echo "[main] Error: only x86-64 & aarch64 architecture is supported for now!"; exit 1; -fi - -# ethos-u -ethos_u_repo_url="https://review.mlplatform.org/ml/ethos-u/ethos-u" -ethos_u_base_rev="0995223100e3da8011700f58e491f1bf59511e3c" - -######## -### Mandatory user args -######## -eula_acceptance="${1:-'.'}"; shift -if [[ "${eula_acceptance}" != "--i-agree-to-the-contained-eula" ]]; then - echo "Must pass first positional argument '--i-agree-to-the-contained-eula' to agree to EULA associated with downloading the FVP. Exiting!" - exit 1 -fi - -######## -### Optional user args -######## -root_dir=${1:-"${script_dir}/ethos-u-scratch"} -root_dir=$(realpath ${root_dir}) - -######## -### Functions -######## - -function setup_fvp() { - # Download and install the Corstone 300 FVP simulator platform - cd "${root_dir}" - if [[ ! -e FVP_cs300.tgz ]]; then - echo "[${FUNCNAME[0]}] Downloading FVP ..." - curl --output FVP_cs300.tgz "${fvp_url}" - verify_md5 ${fvp_md5_checksum} FVP_cs300.tgz - fi - - echo "[${FUNCNAME[0]}] Installing FVP ..." - rm -rf FVP - mkdir -p FVP - cd FVP - tar xf ../FVP_cs300.tgz - ./FVP_Corstone_SSE-300.sh --i-agree-to-the-contained-eula --force --destination ./ --quiet --no-interactive - - fvp_bin_path="$(cd models/${fvp_model_dir} && pwd)" - export PATH=${PATH}:${fvp_bin_path} - - hash FVP_Corstone_SSE-300_Ethos-U55 - echo "export PATH=\${PATH}:${fvp_bin_path}" >> ${setup_path_script} - -} - -function setup_toolchain() { - # Download and install the arm-none-eabi toolchain - cd "${root_dir}" - if [[ ! -e gcc.tar.xz ]]; then - echo "[${FUNCNAME[0]}] Downloading toolchain ..." - curl --output gcc.tar.xz "${toolchain_url}" - verify_md5 ${toolchain_md5_checksum} gcc.tar.xz - fi - - echo "[${FUNCNAME[0]}] Installing toolchain ..." - rm -rf "${toolchain_dir}" - tar xf gcc.tar.xz - toolchain_bin_path="$(cd ${toolchain_dir}/bin && pwd)" - export PATH=${PATH}:${toolchain_bin_path} - hash arm-none-eabi-gcc - echo "export PATH=\${PATH}:${toolchain_bin_path}" >> ${setup_path_script} -} - -function setup_ethos_u() { - # This is the main dir which will pull more repos to do baremetal software dev for cs300 - echo "[${FUNCNAME[0]}] Setting up the repo" - cd "${root_dir}" - [[ ! -d ethos-u ]] && \ - git clone ${ethos_u_repo_url} - cd ethos-u - git reset --hard ${ethos_u_base_rev} - python3 ./fetch_externals.py fetch - pip install pyelftools - echo "[${FUNCNAME[0]}] Done @ $(git describe --all --long 3> /dev/null) in ${root_dir}/ethos-u dir." -} - -function patch_repo() { - # This is a temporary hack until it finds a better home in one for the ARM Ml repos - name="$(basename $repo_dir)" - echo -e "[${FUNCNAME[0]}] Preparing ${name}..." - cd $repo_dir - - git reset --hard ${base_rev} - - patch_dir=${script_dir}/ethos-u-setup/${name}/patches/ - [[ -e ${patch_dir} && $(ls -A ${patch_dir}) ]] && \ - git am -3 ${patch_dir}/*.patch - - echo -e "[${FUNCNAME[0]}] Patched ${name} @ $(git describe --all --long 2> /dev/null) in ${repo_dir} dir.\n" -} - -function setup_tosa_reference_model() { - # The debug flow on the host includes running on a reference implementation of TOSA - # This is useful primarily for debug of quantization accuracy, but also for internal - # errors for the early codebase - cd "${root_dir}" - if [[ ! -e reference_model ]]; then - git clone https://review.mlplatform.org/tosa/reference_model -b main - cd reference_model - git submodule update --init --recursive - cd .. - fi - cd reference_model - mkdir -p build - cd build - cmake .. - n=$(nproc) - make -j"$((n - 5))" - cd reference_model - tosa_bin_path=`pwd` - echo "export PATH=\${PATH}:${tosa_bin_path}" >> "${setup_path_script}" -} - -function setup_vela() { - # - # Prepare the Vela compiler for AoT to Ethos-U compilation - # - cd "${root_dir}" - if [[ ! -e ethos-u-vela ]]; then - git clone https://review.mlplatform.org/ml/ethos-u/ethos-u-vela - repo_dir="${root_dir}/ethos-u-vela" - base_rev=00a15db3e1a188b25065d095152d701f4394cdc5 - patch_repo - fi - cd "${root_dir}/ethos-u-vela" - pip install . -} - -######## -### main -######## -# do basic checks -# Make sure we are on a supported platform -[[ $(get_cpu_arch) != "x86_64" ]] && [[ $(get_cpu_arch) != "aarch64" ]] \ - && { echo "[main] Error: only x86-64 & aarch64 architecture is supported for now!"; exit 1; } - -# No OSx support for FVP -[[ "$(get_os_name)" != "Linux" ]] \ - && { echo "[main] Error: only Linux os is supported for now!"; exit 1; } - -cd "${script_dir}" - -# Setup the root dir -mkdir -p "${root_dir}" -cd "${root_dir}" -echo "[main] Using root dir ${root_dir}" - -setup_path_script="${root_dir}/setup_path.sh" -echo "" > "${setup_path_script}" - -# Setup FVP -setup_fvp - -# Setup toolchain -setup_toolchain - -# Setup the ethos-u dev environment -setup_ethos_u - -# Patch the ethos-u dev environment to include executorch application -repo_dir="${root_dir}/ethos-u/core_platform" -base_rev=204210b1074071532627da9dc69950d058a809f4 -patch_repo - -# Setup the tosa_reference_model -setup_tosa_reference_model - -# Setup vela and patch in codegen fixes -setup_vela - -echo "[main] update path by doing 'source ${setup_path_script}'" - -echo "[main] success!" -exit 0 diff --git a/examples/arm/setup.sh b/examples/arm/setup.sh new file mode 120000 index 00000000000..7c0e1f91d88 --- /dev/null +++ b/examples/arm/setup.sh @@ -0,0 +1 @@ +../../.ci/docker/examples/arm/setup.sh \ No newline at end of file diff --git a/requirements-lintrunner.txt b/requirements-lintrunner.txt deleted file mode 100644 index e5caf38c59e..00000000000 --- a/requirements-lintrunner.txt +++ /dev/null @@ -1,22 +0,0 @@ -# Lintrunner itself -lintrunner==0.11.0 -lintrunner-adapters==0.11.0 - -# Flake 8 and its dependencies -flake8==6.0.0 -flake8-breakpoint==1.1.0 -flake8-bugbear==23.6.5 -flake8-comprehensions==3.12.0 -flake8-pyi==23.5.0 -mccabe==0.7.0 -pycodestyle==2.10.0 -torchfix==0.1.1 - -# UFMT -black==22.12.0 -ufmt==2.0.1 -usort==1.0.5 - -# Other linters -clang-format==12.0.1 -cmakelint==1.4.1 diff --git a/requirements-lintrunner.txt b/requirements-lintrunner.txt new file mode 120000 index 00000000000..7a05642a591 --- /dev/null +++ b/requirements-lintrunner.txt @@ -0,0 +1 @@ +.ci/docker/requirements-lintrunner.txt \ No newline at end of file From a866016d7b42b69036239bc7eb8f198b409ca67c Mon Sep 17 00:00:00 2001 From: Huy Do Date: Tue, 9 Jan 2024 19:37:00 -0800 Subject: [PATCH 2/3] Remove redundant triggers --- .github/workflows/docker-builds.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/docker-builds.yml b/.github/workflows/docker-builds.yml index f48a5ab6f3c..c5b76d357db 100644 --- a/.github/workflows/docker-builds.yml +++ b/.github/workflows/docker-builds.yml @@ -6,8 +6,6 @@ on: paths: - .ci/docker/** - .github/workflows/docker-builds.yml - - requirements-lintrunner.txt - - examples/arm/** push: branches: - main @@ -15,8 +13,6 @@ on: paths: - .ci/docker/** - .github/workflows/docker-builds.yml - - requirements-lintrunner.txt - - examples/arm/** schedule: - cron: 1 3 * * 3 From 559cd994b2381e178686e5540173dfc8148f6dd0 Mon Sep 17 00:00:00 2001 From: Huy Do Date: Tue, 9 Jan 2024 20:21:45 -0800 Subject: [PATCH 3/3] Create links to play nicely with fbcode --- examples/arm/ethos-u-setup | 1 - examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake | 1 + .../core_platform/patches/0001-Executorch-Add-README.patch | 1 + ...02-Executorch-local-patch-regress-cmake-version-from-3..patch | 1 + ...03-Executorch-local-patch-Disable-warnings-to-reduce-ve.patch | 1 + .../0004-Executorch-local-patch-New-phdr-for-.data-section.patch | 1 + .../patches/0005-Executorch-Add-pte-to-header-script.patch | 1 + .../patches/0006-Executorch-Add-executorch_runner-test.patch | 1 + .../patches/0007-Executorch-Add-delegate-runner-test.patch | 1 + .../patches/0008-Use-new-LIB_ET_OP_REGISTRATION-lib-path.patch | 1 + .../0009-Executorch-Use-libportable_ops_lib-instead.patch | 1 + .../patches/0001-Improve-rescale-codegen-for-TOSA.patch | 1 + 12 files changed, 11 insertions(+), 1 deletion(-) delete mode 120000 examples/arm/ethos-u-setup create mode 120000 examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake create mode 120000 examples/arm/ethos-u-setup/core_platform/patches/0001-Executorch-Add-README.patch create mode 120000 examples/arm/ethos-u-setup/core_platform/patches/0002-Executorch-local-patch-regress-cmake-version-from-3..patch create mode 120000 examples/arm/ethos-u-setup/core_platform/patches/0003-Executorch-local-patch-Disable-warnings-to-reduce-ve.patch create mode 120000 examples/arm/ethos-u-setup/core_platform/patches/0004-Executorch-local-patch-New-phdr-for-.data-section.patch create mode 120000 examples/arm/ethos-u-setup/core_platform/patches/0005-Executorch-Add-pte-to-header-script.patch create mode 120000 examples/arm/ethos-u-setup/core_platform/patches/0006-Executorch-Add-executorch_runner-test.patch create mode 120000 examples/arm/ethos-u-setup/core_platform/patches/0007-Executorch-Add-delegate-runner-test.patch create mode 120000 examples/arm/ethos-u-setup/core_platform/patches/0008-Use-new-LIB_ET_OP_REGISTRATION-lib-path.patch create mode 120000 examples/arm/ethos-u-setup/core_platform/patches/0009-Executorch-Use-libportable_ops_lib-instead.patch create mode 120000 examples/arm/ethos-u-setup/ethos-u-vela/patches/0001-Improve-rescale-codegen-for-TOSA.patch diff --git a/examples/arm/ethos-u-setup b/examples/arm/ethos-u-setup deleted file mode 120000 index f88ac4458b7..00000000000 --- a/examples/arm/ethos-u-setup +++ /dev/null @@ -1 +0,0 @@ -../../.ci/docker/examples/arm/ethos-u-setup \ No newline at end of file diff --git a/examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake b/examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake new file mode 120000 index 00000000000..14f678c44ec --- /dev/null +++ b/examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake @@ -0,0 +1 @@ +../../../.ci/docker/examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake \ No newline at end of file diff --git a/examples/arm/ethos-u-setup/core_platform/patches/0001-Executorch-Add-README.patch b/examples/arm/ethos-u-setup/core_platform/patches/0001-Executorch-Add-README.patch new file mode 120000 index 00000000000..0740aff3b9f --- /dev/null +++ b/examples/arm/ethos-u-setup/core_platform/patches/0001-Executorch-Add-README.patch @@ -0,0 +1 @@ +../../../../../.ci/docker/examples/arm/ethos-u-setup/core_platform/patches/0001-Executorch-Add-README.patch \ No newline at end of file diff --git a/examples/arm/ethos-u-setup/core_platform/patches/0002-Executorch-local-patch-regress-cmake-version-from-3..patch b/examples/arm/ethos-u-setup/core_platform/patches/0002-Executorch-local-patch-regress-cmake-version-from-3..patch new file mode 120000 index 00000000000..be96eebc4e5 --- /dev/null +++ b/examples/arm/ethos-u-setup/core_platform/patches/0002-Executorch-local-patch-regress-cmake-version-from-3..patch @@ -0,0 +1 @@ +../../../../../.ci/docker/examples/arm/ethos-u-setup/core_platform/patches/0002-Executorch-local-patch-regress-cmake-version-from-3..patch \ No newline at end of file diff --git a/examples/arm/ethos-u-setup/core_platform/patches/0003-Executorch-local-patch-Disable-warnings-to-reduce-ve.patch b/examples/arm/ethos-u-setup/core_platform/patches/0003-Executorch-local-patch-Disable-warnings-to-reduce-ve.patch new file mode 120000 index 00000000000..e27184c030b --- /dev/null +++ b/examples/arm/ethos-u-setup/core_platform/patches/0003-Executorch-local-patch-Disable-warnings-to-reduce-ve.patch @@ -0,0 +1 @@ +../../../../../.ci/docker/examples/arm/ethos-u-setup/core_platform/patches/0003-Executorch-local-patch-Disable-warnings-to-reduce-ve.patch \ No newline at end of file diff --git a/examples/arm/ethos-u-setup/core_platform/patches/0004-Executorch-local-patch-New-phdr-for-.data-section.patch b/examples/arm/ethos-u-setup/core_platform/patches/0004-Executorch-local-patch-New-phdr-for-.data-section.patch new file mode 120000 index 00000000000..0dd6bf9953c --- /dev/null +++ b/examples/arm/ethos-u-setup/core_platform/patches/0004-Executorch-local-patch-New-phdr-for-.data-section.patch @@ -0,0 +1 @@ +../../../../../.ci/docker/examples/arm/ethos-u-setup/core_platform/patches/0004-Executorch-local-patch-New-phdr-for-.data-section.patch \ No newline at end of file diff --git a/examples/arm/ethos-u-setup/core_platform/patches/0005-Executorch-Add-pte-to-header-script.patch b/examples/arm/ethos-u-setup/core_platform/patches/0005-Executorch-Add-pte-to-header-script.patch new file mode 120000 index 00000000000..ab98ad0e929 --- /dev/null +++ b/examples/arm/ethos-u-setup/core_platform/patches/0005-Executorch-Add-pte-to-header-script.patch @@ -0,0 +1 @@ +../../../../../.ci/docker/examples/arm/ethos-u-setup/core_platform/patches/0005-Executorch-Add-pte-to-header-script.patch \ No newline at end of file diff --git a/examples/arm/ethos-u-setup/core_platform/patches/0006-Executorch-Add-executorch_runner-test.patch b/examples/arm/ethos-u-setup/core_platform/patches/0006-Executorch-Add-executorch_runner-test.patch new file mode 120000 index 00000000000..98cfad8a516 --- /dev/null +++ b/examples/arm/ethos-u-setup/core_platform/patches/0006-Executorch-Add-executorch_runner-test.patch @@ -0,0 +1 @@ +../../../../../.ci/docker/examples/arm/ethos-u-setup/core_platform/patches/0006-Executorch-Add-executorch_runner-test.patch \ No newline at end of file diff --git a/examples/arm/ethos-u-setup/core_platform/patches/0007-Executorch-Add-delegate-runner-test.patch b/examples/arm/ethos-u-setup/core_platform/patches/0007-Executorch-Add-delegate-runner-test.patch new file mode 120000 index 00000000000..f918a80cbf0 --- /dev/null +++ b/examples/arm/ethos-u-setup/core_platform/patches/0007-Executorch-Add-delegate-runner-test.patch @@ -0,0 +1 @@ +../../../../../.ci/docker/examples/arm/ethos-u-setup/core_platform/patches/0007-Executorch-Add-delegate-runner-test.patch \ No newline at end of file diff --git a/examples/arm/ethos-u-setup/core_platform/patches/0008-Use-new-LIB_ET_OP_REGISTRATION-lib-path.patch b/examples/arm/ethos-u-setup/core_platform/patches/0008-Use-new-LIB_ET_OP_REGISTRATION-lib-path.patch new file mode 120000 index 00000000000..5488a625f9c --- /dev/null +++ b/examples/arm/ethos-u-setup/core_platform/patches/0008-Use-new-LIB_ET_OP_REGISTRATION-lib-path.patch @@ -0,0 +1 @@ +../../../../../.ci/docker/examples/arm/ethos-u-setup/core_platform/patches/0008-Use-new-LIB_ET_OP_REGISTRATION-lib-path.patch \ No newline at end of file diff --git a/examples/arm/ethos-u-setup/core_platform/patches/0009-Executorch-Use-libportable_ops_lib-instead.patch b/examples/arm/ethos-u-setup/core_platform/patches/0009-Executorch-Use-libportable_ops_lib-instead.patch new file mode 120000 index 00000000000..3277c23b894 --- /dev/null +++ b/examples/arm/ethos-u-setup/core_platform/patches/0009-Executorch-Use-libportable_ops_lib-instead.patch @@ -0,0 +1 @@ +../../../../../.ci/docker/examples/arm/ethos-u-setup/core_platform/patches/0009-Executorch-Use-libportable_ops_lib-instead.patch \ No newline at end of file diff --git a/examples/arm/ethos-u-setup/ethos-u-vela/patches/0001-Improve-rescale-codegen-for-TOSA.patch b/examples/arm/ethos-u-setup/ethos-u-vela/patches/0001-Improve-rescale-codegen-for-TOSA.patch new file mode 120000 index 00000000000..d012bebc0ab --- /dev/null +++ b/examples/arm/ethos-u-setup/ethos-u-vela/patches/0001-Improve-rescale-codegen-for-TOSA.patch @@ -0,0 +1 @@ +../../../../../.ci/docker/examples/arm/ethos-u-setup/ethos-u-vela/patches/0001-Improve-rescale-codegen-for-TOSA.patch \ No newline at end of file