-
Notifications
You must be signed in to change notification settings - Fork 453
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Zonglin Peng
committed
Feb 23, 2025
1 parent
366d87e
commit 9ddcaf5
Showing
8 changed files
with
347 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/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 -ex | ||
|
||
# Double check if the cadence version is set, | ||
# TODO: set and read DSP names from secrets | ||
[ -n "${CADENCE_SDK}" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#!/bin/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 -euo pipefail | ||
|
||
unset CMAKE_PREFIX_PATH | ||
unset XTENSA_CORE | ||
export XTENSA_CORE=FCV_FG3GP | ||
git submodule sync | ||
git submodule update --init | ||
./backends/cadence/install_requirements.sh | ||
./install_executorch.sh | ||
|
||
rm -rf cmake-out | ||
|
||
STEPWISE_BUILD=false | ||
|
||
if $STEPWISE_BUILD; then | ||
echo "Building ExecuTorch" | ||
CXXFLAGS="-fno-exceptions -fno-rtti" cmake -DCMAKE_INSTALL_PREFIX=cmake-out \ | ||
-DCMAKE_TOOLCHAIN_FILE=./backends/cadence/cadence.cmake \ | ||
-DCMAKE_BUILD_TYPE=Release \ | ||
-DEXECUTORCH_ENABLE_EVENT_TRACER=OFF \ | ||
-DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \ | ||
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON \ | ||
-DEXECUTORCH_BUILD_PTHREADPOOL=OFF \ | ||
-DEXECUTORCH_BUILD_CPUINFO=OFF \ | ||
-DEXECUTORCH_ENABLE_LOGGING=ON \ | ||
-DEXECUTORCH_USE_DL=OFF \ | ||
-DEXECUTORCH_BUILD_CADENCE=OFF \ | ||
-DFLATC_EXECUTABLE="$(which flatc)" \ | ||
-DHAVE_FNMATCH_H=OFF \ | ||
-Bcmake-out . | ||
|
||
echo "Building any Cadence-specific binaries on top" | ||
CXXFLAGS="-fno-exceptions -fno-rtti" cmake -DBUCK2="$BUCK" \ | ||
-DCMAKE_TOOLCHAIN_FILE=/home/zonglinpeng/ws/zonglinpeng/executorch/backends/cadence/cadence.cmake \ | ||
-DCMAKE_INSTALL_PREFIX=cmake-out \ | ||
-DCMAKE_BUILD_TYPE=Release \ | ||
-DEXECUTORCH_BUILD_HOST_TARGETS=ON \ | ||
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON \ | ||
-DEXECUTORCH_BUILD_PTHREADPOOL=OFF \ | ||
-DEXECUTORCH_BUILD_CADENCE=ON \ | ||
-DFLATC_EXECUTABLE="$(which flatc)" \ | ||
-DEXECUTORCH_ENABLE_LOGGING=ON \ | ||
-DEXECUTORCH_ENABLE_PROGRAM_VERIFICATION=ON \ | ||
-DEXECUTORCH_USE_DL=OFF \ | ||
-DBUILD_EXECUTORCH_PORTABLE_OPS=ON \ | ||
-DEXECUTORCH_BUILD_KERNELS_CUSTOM=OFF \ | ||
-DPYTHON_EXECUTABLE=python3 \ | ||
-DEXECUTORCH_FUSION_G3_OPT=ON \ | ||
-DEXECUTORCH_BUILD_GFLAGS=ON \ | ||
-DHAVE_FNMATCH_H=OFF \ | ||
-Bcmake-out/backends/cadence \ | ||
backends/cadence | ||
cmake --build cmake-out/backends/cadence -j8 | ||
else | ||
echo "Building Cadence toolchain with ExecuTorch packages" | ||
cmake_prefix_path="${PWD}/cmake-out/lib/cmake/ExecuTorch;${PWD}/cmake-out/third-party/gflags" | ||
CXXFLAGS="-fno-exceptions -fno-rtti" cmake -DBUCK2="$BUCK" \ | ||
-DCMAKE_PREFIX_PATH="${cmake_prefix_path}" \ | ||
-DHAVE_SYS_STAT_H=ON \ | ||
-DCMAKE_TOOLCHAIN_FILE=./backends/cadence/cadence.cmake \ | ||
-DCMAKE_INSTALL_PREFIX=cmake-out \ | ||
-DCMAKE_BUILD_TYPE=Release \ | ||
-DEXECUTORCH_BUILD_HOST_TARGETS=ON \ | ||
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON \ | ||
-DEXECUTORCH_BUILD_PTHREADPOOL=OFF \ | ||
-DEXECUTORCH_BUILD_CPUINFO=OFF \ | ||
-DEXECUTORCH_BUILD_FLATC=OFF \ | ||
-DEXECUTORCH_BUILD_CADENCE=ON \ | ||
-DFLATC_EXECUTABLE="$(which flatc)" \ | ||
-DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \ | ||
-DEXECUTORCH_ENABLE_LOGGING=ON \ | ||
-DEXECUTORCH_ENABLE_PROGRAM_VERIFICATION=ON \ | ||
-DEXECUTORCH_USE_DL=OFF \ | ||
-DBUILD_EXECUTORCH_PORTABLE_OPS=ON \ | ||
-DEXECUTORCH_BUILD_KERNELS_CUSTOM=OFF \ | ||
-DPYTHON_EXECUTABLE=python3 \ | ||
-DEXECUTORCH_FUSION_G3_OPT=ON \ | ||
-DHAVE_FNMATCH_H=OFF \ | ||
-Bcmake-out | ||
cmake --build cmake-out --target install --config Release -j8 | ||
fi | ||
|
||
echo "Run simple model to verify cmake build" | ||
python3 -m examples.portable.scripts.export --model_name="add" | ||
xt-run --turbo cmake-out/executor_runner --model_path=add.pte |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#!/bin/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 -euo pipefail | ||
|
||
unset CMAKE_PREFIX_PATH | ||
unset XTENSA_CORE | ||
export XTENSA_CORE=nxp_rt600_RI23_11_newlib | ||
git submodule sync | ||
git submodule update --init | ||
./backends/cadence/install_requirements.sh | ||
./install_executorch.sh | ||
|
||
rm -rf cmake-out | ||
|
||
STEPWISE_BUILD=false | ||
|
||
if $STEPWISE_BUILD; then | ||
echo "Building ExecuTorch" | ||
CXXFLAGS="-fno-exceptions -fno-rtti" cmake -DCMAKE_INSTALL_PREFIX=cmake-out \ | ||
-DCMAKE_TOOLCHAIN_FILE=./backends/cadence/cadence.cmake \ | ||
-DCMAKE_BUILD_TYPE=Release \ | ||
-DEXECUTORCH_ENABLE_EVENT_TRACER=OFF \ | ||
-DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \ | ||
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=OFF \ | ||
-DEXECUTORCH_BUILD_PTHREADPOOL=OFF \ | ||
-DEXECUTORCH_BUILD_CPUINFO=OFF \ | ||
-DEXECUTORCH_ENABLE_LOGGING=ON \ | ||
-DEXECUTORCH_USE_DL=OFF \ | ||
-DEXECUTORCH_BUILD_CADENCE=OFF \ | ||
-DFLATC_EXECUTABLE="$(which flatc)" \ | ||
-Bcmake-out . | ||
|
||
echo "Building any Cadence-specific binaries on top" | ||
CXXFLAGS="-fno-exceptions -fno-rtti" cmake -DBUCK2="$BUCK" \ | ||
-DCMAKE_TOOLCHAIN_FILE=./backends/cadence/cadence.cmake \ | ||
-DCMAKE_INSTALL_PREFIX=cmake-out \ | ||
-DCMAKE_BUILD_TYPE=Release \ | ||
-DEXECUTORCH_BUILD_HOST_TARGETS=ON \ | ||
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON \ | ||
-DEXECUTORCH_BUILD_PTHREADPOOL=OFF \ | ||
-DEXECUTORCH_BUILD_CADENCE=ON \ | ||
-DFLATC_EXECUTABLE="$(which flatc)" \ | ||
-DEXECUTORCH_ENABLE_LOGGING=ON \ | ||
-DEXECUTORCH_ENABLE_PROGRAM_VERIFICATION=ON \ | ||
-DEXECUTORCH_USE_DL=OFF \ | ||
-DBUILD_EXECUTORCH_PORTABLE_OPS=ON \ | ||
-DEXECUTORCH_BUILD_KERNELS_CUSTOM=OFF \ | ||
-DPYTHON_EXECUTABLE=python3 \ | ||
-DEXECUTORCH_NNLIB_OPT=ON \ | ||
-DEXECUTORCH_BUILD_GFLAGS=ON \ | ||
-DHAVE_FNMATCH_H=OFF \ | ||
-Bcmake-out/backends/cadence \ | ||
backends/cadence | ||
cmake --build cmake-out/backends/cadence -j8 | ||
else | ||
echo "Building Cadence toolchain with ExecuTorch packages" | ||
cmake_prefix_path="${PWD}/cmake-out/lib/cmake/ExecuTorch;${PWD}/cmake-out/third-party/gflags" | ||
CXXFLAGS="-fno-exceptions -fno-rtti" cmake -DBUCK2="$BUCK" \ | ||
-DCMAKE_PREFIX_PATH="${cmake_prefix_path}" \ | ||
-DCMAKE_TOOLCHAIN_FILE=./backends/cadence/cadence.cmake \ | ||
-DCMAKE_INSTALL_PREFIX=cmake-out \ | ||
-DCMAKE_BUILD_TYPE=Release \ | ||
-DEXECUTORCH_BUILD_HOST_TARGETS=ON \ | ||
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON \ | ||
-DEXECUTORCH_BUILD_PTHREADPOOL=OFF \ | ||
-DEXECUTORCH_BUILD_CPUINFO=OFF \ | ||
-DEXECUTORCH_BUILD_FLATC=OFF \ | ||
-DEXECUTORCH_BUILD_CADENCE=ON \ | ||
-DFLATC_EXECUTABLE="$(which flatc)" \ | ||
-DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \ | ||
-DEXECUTORCH_ENABLE_LOGGING=ON \ | ||
-DEXECUTORCH_ENABLE_PROGRAM_VERIFICATION=ON \ | ||
-DEXECUTORCH_USE_DL=OFF \ | ||
-DBUILD_EXECUTORCH_PORTABLE_OPS=ON \ | ||
-DEXECUTORCH_BUILD_KERNELS_CUSTOM=OFF \ | ||
-DPYTHON_EXECUTABLE=python3 \ | ||
-DEXECUTORCH_NNLIB_OPT=ON \ | ||
-DHAVE_FNMATCH_H=OFF \ | ||
-Bcmake-out | ||
cmake --build cmake-out --target install --config Release -j8 | ||
fi | ||
|
||
echo "Run simple model to verify cmake build" | ||
python3 -m examples.portable.scripts.export --model_name="add" | ||
xt-run --turbo cmake-out/executor_runner --model_path=add.pte |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/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. | ||
|
||
# Builds cadence_runner and prints its path. | ||
|
||
set -euo pipefail | ||
|
||
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" | ||
readonly SCRIPT_DIR | ||
|
||
readonly EXECUTORCH_ROOT="${SCRIPT_DIR}/../.." | ||
|
||
# Allow overriding the number of build jobs. Default to 9. | ||
export CMAKE_BUILD_PARALLEL_LEVEL="${CMAKE_BUILD_PARALLEL_LEVEL:-9}" | ||
|
||
main() { | ||
cd "${EXECUTORCH_ROOT}" | ||
|
||
rm -rf cmake-out | ||
CXXFLAGS="-fno-exceptions -fno-rtti" cmake -DCMAKE_INSTALL_PREFIX=cmake-out \ | ||
-DCMAKE_BUILD_TYPE=Release \ | ||
-DEXECUTORCH_BUILD_DEVTOOLS=ON \ | ||
-DEXECUTORCH_ENABLE_EVENT_TRACER=ON \ | ||
-DEXECUTORCH_ENABLE_LOGGING=ON \ | ||
-Bcmake-out . | ||
cmake --build cmake-out --target install --config Release -j16 | ||
|
||
local example_dir=backends/cadence | ||
local build_dir="cmake-out/${example_dir}" | ||
local cmake_prefix_path="${PWD}/cmake-out/lib/cmake/ExecuTorch;${PWD}/cmake-out/third-party/gflags" | ||
rm -rf ${build_dir} | ||
CXXFLAGS="-fno-exceptions -fno-rtti" cmake -DCMAKE_PREFIX_PATH="${cmake_prefix_path}" \ | ||
-DCMAKE_BUILD_TYPE=Release \ | ||
-DEXECUTORCH_CADENCE_CPU_RUNNER=ON \ | ||
-DEXECUTORCH_ENABLE_LOGGING=ON \ | ||
-B"${build_dir}" \ | ||
"${example_dir}" | ||
cmake --build "${build_dir}" --config Release -j16 | ||
|
||
local runner="${PWD}/${build_dir}/cadence_runner" | ||
if [[ ! -f "${runner}" ]]; then | ||
echo "ERROR: Failed to build ${build_dir}/cadence_runner" >&2 | ||
exit 1 | ||
else | ||
echo "Built ${build_dir}/cadence_runner" | ||
fi | ||
} | ||
|
||
main "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
name: cadence-build | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- release/* | ||
pull_request: | ||
paths: | ||
# - .ci/scripts/setup-cadence.sh | ||
- .github/workflows/apple.yml | ||
- install_executorch.sh | ||
- backends/cadence/** | ||
- examples/cadence/** | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '0 10 * * *' # Runs daily at 2 AM PST | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}-${{ github.event_name == 'schedule' }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
setup-env: | ||
name: setup-env | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: "3.10" | ||
|
||
set-envir-vars: | ||
name: set-envir-vars | ||
runs-on: ubuntu-22.04 | ||
needs: setup-env | ||
outputs: | ||
version: ${{ steps.set_version.outputs.version }} | ||
steps: | ||
- name: Set VERSION variable | ||
id: set_version | ||
shell: bash | ||
run: | | ||
VERSION="0.5.0.$(TZ='PST8PDT' date +%Y%m%d)" | ||
echo "version=$VERSION" >> "$GITHUB_OUTPUT" | ||
cpu-build: | ||
name: cpu-build | ||
needs: set-envir-vars | ||
# uses: pytorch/test-infra/.github/workflows/macos_job.yml@main | ||
# secrets: inherit | ||
steps: | ||
- name: install executorch | ||
shell: bash | ||
run: | | ||
BUILD_TOOL="cmake" | ||
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}" | ||
- name: run cadence cpu build script | ||
shell: bash | ||
run: | | ||
.ci/scripts/build_cadence_runner.sh | ||
g3-build: | ||
# NB: Don't run this on fork PRs because they won't have access to the secret and would fail anyway | ||
if: ${{ !github.event.pull_request.head.repo.fork }} | ||
runs-on: ubuntu-22.04 | ||
hifi-build: | ||
# NB: Don't run this on fork PRs because they won't have access to the secret and would fail anyway | ||
if: ${{ !github.event.pull_request.head.repo.fork }} | ||
runs-on: ubuntu-22.04 | ||
mv130-build: | ||
# NB: Don't run this on fork PRs because they won't have access to the secret and would fail anyway | ||
if: ${{ !github.event.pull_request.head.repo.fork }} | ||
runs-on: ubuntu-22.04 | ||
hifi-build: | ||
# NB: Don't run this on fork PRs because they won't have access to the secret and would fail anyway | ||
if: ${{ !github.event.pull_request.head.repo.fork }} | ||
runs-on: ubuntu-22.04 | ||
# uses: pytorch/test-infra/.github/workflows/macos_job.yml@main | ||
# secrets: inherit | ||
with: | ||
runner: linux.2xlarge | ||
docker-image: executorch-ubuntu-22.04-cadence-sdk | ||
fetch-depth: 0 | ||
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} | ||
timeout: 90 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters