Skip to content

Commit 9ddcaf5

Browse files
author
Zonglin Peng
committed
init
1 parent 366d87e commit 9ddcaf5

File tree

8 files changed

+347
-0
lines changed

8 files changed

+347
-0
lines changed

.ci/docker/build.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ case "${IMAGE_NAME}" in
4141
QNN_SDK=yes
4242
CLANG_VERSION=12
4343
;;
44+
executorch-ubuntu-22.04-cadence-sdk)
45+
CADENCE_SDK=yes
46+
CLANG_VERSION=12
47+
;;
4448
executorch-ubuntu-22.04-mediatek-sdk)
4549
MEDIATEK_SDK=yes
4650
CLANG_VERSION=12
@@ -81,6 +85,7 @@ docker build \
8185
--build-arg "BUILD_DOCS=${BUILD_DOCS}" \
8286
--build-arg "ARM_SDK=${ARM_SDK:-}" \
8387
--build-arg "QNN_SDK=${QNN_SDK:-}" \
88+
--build-arg "CADENCE_SDK=${CADENCE_SDK:-}" \
8489
--build-arg "MEDIATEK_SDK=${MEDIATEK_SDK:-}" \
8590
--build-arg "ANDROID_NDK_VERSION=${ANDROID_NDK_VERSION:-}" \
8691
-f "${OS}"/Dockerfile \
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
set -ex
9+
10+
# Double check if the cadence version is set,
11+
# TODO: set and read DSP names from secrets
12+
[ -n "${CADENCE_SDK}" ]

.ci/docker/ubuntu/Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ ARG ARM_SDK
8282

8383
ARG QNN_SDK
8484

85+
ARG CADENCE_SDK
86+
# Install cadence if needed
87+
COPY ./common/install_cadence.sh install_cadence.sh
88+
RUN if [ -n "${CADENCE_SDK}" ]; then bash ./install_cadence.sh; fi
89+
RUN rm install_cadence.sh
90+
91+
8592
ARG MEDIATEK_SDK
8693

8794
USER ci-user
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
set -euo pipefail
9+
10+
unset CMAKE_PREFIX_PATH
11+
unset XTENSA_CORE
12+
export XTENSA_CORE=FCV_FG3GP
13+
git submodule sync
14+
git submodule update --init
15+
./backends/cadence/install_requirements.sh
16+
./install_executorch.sh
17+
18+
rm -rf cmake-out
19+
20+
STEPWISE_BUILD=false
21+
22+
if $STEPWISE_BUILD; then
23+
echo "Building ExecuTorch"
24+
CXXFLAGS="-fno-exceptions -fno-rtti" cmake -DCMAKE_INSTALL_PREFIX=cmake-out \
25+
-DCMAKE_TOOLCHAIN_FILE=./backends/cadence/cadence.cmake \
26+
-DCMAKE_BUILD_TYPE=Release \
27+
-DEXECUTORCH_ENABLE_EVENT_TRACER=OFF \
28+
-DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
29+
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON \
30+
-DEXECUTORCH_BUILD_PTHREADPOOL=OFF \
31+
-DEXECUTORCH_BUILD_CPUINFO=OFF \
32+
-DEXECUTORCH_ENABLE_LOGGING=ON \
33+
-DEXECUTORCH_USE_DL=OFF \
34+
-DEXECUTORCH_BUILD_CADENCE=OFF \
35+
-DFLATC_EXECUTABLE="$(which flatc)" \
36+
-DHAVE_FNMATCH_H=OFF \
37+
-Bcmake-out .
38+
39+
echo "Building any Cadence-specific binaries on top"
40+
CXXFLAGS="-fno-exceptions -fno-rtti" cmake -DBUCK2="$BUCK" \
41+
-DCMAKE_TOOLCHAIN_FILE=/home/zonglinpeng/ws/zonglinpeng/executorch/backends/cadence/cadence.cmake \
42+
-DCMAKE_INSTALL_PREFIX=cmake-out \
43+
-DCMAKE_BUILD_TYPE=Release \
44+
-DEXECUTORCH_BUILD_HOST_TARGETS=ON \
45+
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON \
46+
-DEXECUTORCH_BUILD_PTHREADPOOL=OFF \
47+
-DEXECUTORCH_BUILD_CADENCE=ON \
48+
-DFLATC_EXECUTABLE="$(which flatc)" \
49+
-DEXECUTORCH_ENABLE_LOGGING=ON \
50+
-DEXECUTORCH_ENABLE_PROGRAM_VERIFICATION=ON \
51+
-DEXECUTORCH_USE_DL=OFF \
52+
-DBUILD_EXECUTORCH_PORTABLE_OPS=ON \
53+
-DEXECUTORCH_BUILD_KERNELS_CUSTOM=OFF \
54+
-DPYTHON_EXECUTABLE=python3 \
55+
-DEXECUTORCH_FUSION_G3_OPT=ON \
56+
-DEXECUTORCH_BUILD_GFLAGS=ON \
57+
-DHAVE_FNMATCH_H=OFF \
58+
-Bcmake-out/backends/cadence \
59+
backends/cadence
60+
cmake --build cmake-out/backends/cadence -j8
61+
else
62+
echo "Building Cadence toolchain with ExecuTorch packages"
63+
cmake_prefix_path="${PWD}/cmake-out/lib/cmake/ExecuTorch;${PWD}/cmake-out/third-party/gflags"
64+
CXXFLAGS="-fno-exceptions -fno-rtti" cmake -DBUCK2="$BUCK" \
65+
-DCMAKE_PREFIX_PATH="${cmake_prefix_path}" \
66+
-DHAVE_SYS_STAT_H=ON \
67+
-DCMAKE_TOOLCHAIN_FILE=./backends/cadence/cadence.cmake \
68+
-DCMAKE_INSTALL_PREFIX=cmake-out \
69+
-DCMAKE_BUILD_TYPE=Release \
70+
-DEXECUTORCH_BUILD_HOST_TARGETS=ON \
71+
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON \
72+
-DEXECUTORCH_BUILD_PTHREADPOOL=OFF \
73+
-DEXECUTORCH_BUILD_CPUINFO=OFF \
74+
-DEXECUTORCH_BUILD_FLATC=OFF \
75+
-DEXECUTORCH_BUILD_CADENCE=ON \
76+
-DFLATC_EXECUTABLE="$(which flatc)" \
77+
-DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
78+
-DEXECUTORCH_ENABLE_LOGGING=ON \
79+
-DEXECUTORCH_ENABLE_PROGRAM_VERIFICATION=ON \
80+
-DEXECUTORCH_USE_DL=OFF \
81+
-DBUILD_EXECUTORCH_PORTABLE_OPS=ON \
82+
-DEXECUTORCH_BUILD_KERNELS_CUSTOM=OFF \
83+
-DPYTHON_EXECUTABLE=python3 \
84+
-DEXECUTORCH_FUSION_G3_OPT=ON \
85+
-DHAVE_FNMATCH_H=OFF \
86+
-Bcmake-out
87+
cmake --build cmake-out --target install --config Release -j8
88+
fi
89+
90+
echo "Run simple model to verify cmake build"
91+
python3 -m examples.portable.scripts.export --model_name="add"
92+
xt-run --turbo cmake-out/executor_runner --model_path=add.pte

.ci/scripts/build_cadence_hifi4.sh

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
set -euo pipefail
9+
10+
unset CMAKE_PREFIX_PATH
11+
unset XTENSA_CORE
12+
export XTENSA_CORE=nxp_rt600_RI23_11_newlib
13+
git submodule sync
14+
git submodule update --init
15+
./backends/cadence/install_requirements.sh
16+
./install_executorch.sh
17+
18+
rm -rf cmake-out
19+
20+
STEPWISE_BUILD=false
21+
22+
if $STEPWISE_BUILD; then
23+
echo "Building ExecuTorch"
24+
CXXFLAGS="-fno-exceptions -fno-rtti" cmake -DCMAKE_INSTALL_PREFIX=cmake-out \
25+
-DCMAKE_TOOLCHAIN_FILE=./backends/cadence/cadence.cmake \
26+
-DCMAKE_BUILD_TYPE=Release \
27+
-DEXECUTORCH_ENABLE_EVENT_TRACER=OFF \
28+
-DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
29+
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=OFF \
30+
-DEXECUTORCH_BUILD_PTHREADPOOL=OFF \
31+
-DEXECUTORCH_BUILD_CPUINFO=OFF \
32+
-DEXECUTORCH_ENABLE_LOGGING=ON \
33+
-DEXECUTORCH_USE_DL=OFF \
34+
-DEXECUTORCH_BUILD_CADENCE=OFF \
35+
-DFLATC_EXECUTABLE="$(which flatc)" \
36+
-Bcmake-out .
37+
38+
echo "Building any Cadence-specific binaries on top"
39+
CXXFLAGS="-fno-exceptions -fno-rtti" cmake -DBUCK2="$BUCK" \
40+
-DCMAKE_TOOLCHAIN_FILE=./backends/cadence/cadence.cmake \
41+
-DCMAKE_INSTALL_PREFIX=cmake-out \
42+
-DCMAKE_BUILD_TYPE=Release \
43+
-DEXECUTORCH_BUILD_HOST_TARGETS=ON \
44+
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON \
45+
-DEXECUTORCH_BUILD_PTHREADPOOL=OFF \
46+
-DEXECUTORCH_BUILD_CADENCE=ON \
47+
-DFLATC_EXECUTABLE="$(which flatc)" \
48+
-DEXECUTORCH_ENABLE_LOGGING=ON \
49+
-DEXECUTORCH_ENABLE_PROGRAM_VERIFICATION=ON \
50+
-DEXECUTORCH_USE_DL=OFF \
51+
-DBUILD_EXECUTORCH_PORTABLE_OPS=ON \
52+
-DEXECUTORCH_BUILD_KERNELS_CUSTOM=OFF \
53+
-DPYTHON_EXECUTABLE=python3 \
54+
-DEXECUTORCH_NNLIB_OPT=ON \
55+
-DEXECUTORCH_BUILD_GFLAGS=ON \
56+
-DHAVE_FNMATCH_H=OFF \
57+
-Bcmake-out/backends/cadence \
58+
backends/cadence
59+
cmake --build cmake-out/backends/cadence -j8
60+
else
61+
echo "Building Cadence toolchain with ExecuTorch packages"
62+
cmake_prefix_path="${PWD}/cmake-out/lib/cmake/ExecuTorch;${PWD}/cmake-out/third-party/gflags"
63+
CXXFLAGS="-fno-exceptions -fno-rtti" cmake -DBUCK2="$BUCK" \
64+
-DCMAKE_PREFIX_PATH="${cmake_prefix_path}" \
65+
-DCMAKE_TOOLCHAIN_FILE=./backends/cadence/cadence.cmake \
66+
-DCMAKE_INSTALL_PREFIX=cmake-out \
67+
-DCMAKE_BUILD_TYPE=Release \
68+
-DEXECUTORCH_BUILD_HOST_TARGETS=ON \
69+
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON \
70+
-DEXECUTORCH_BUILD_PTHREADPOOL=OFF \
71+
-DEXECUTORCH_BUILD_CPUINFO=OFF \
72+
-DEXECUTORCH_BUILD_FLATC=OFF \
73+
-DEXECUTORCH_BUILD_CADENCE=ON \
74+
-DFLATC_EXECUTABLE="$(which flatc)" \
75+
-DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
76+
-DEXECUTORCH_ENABLE_LOGGING=ON \
77+
-DEXECUTORCH_ENABLE_PROGRAM_VERIFICATION=ON \
78+
-DEXECUTORCH_USE_DL=OFF \
79+
-DBUILD_EXECUTORCH_PORTABLE_OPS=ON \
80+
-DEXECUTORCH_BUILD_KERNELS_CUSTOM=OFF \
81+
-DPYTHON_EXECUTABLE=python3 \
82+
-DEXECUTORCH_NNLIB_OPT=ON \
83+
-DHAVE_FNMATCH_H=OFF \
84+
-Bcmake-out
85+
cmake --build cmake-out --target install --config Release -j8
86+
fi
87+
88+
echo "Run simple model to verify cmake build"
89+
python3 -m examples.portable.scripts.export --model_name="add"
90+
xt-run --turbo cmake-out/executor_runner --model_path=add.pte
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
# Builds cadence_runner and prints its path.
9+
10+
set -euo pipefail
11+
12+
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
13+
readonly SCRIPT_DIR
14+
15+
readonly EXECUTORCH_ROOT="${SCRIPT_DIR}/../.."
16+
17+
# Allow overriding the number of build jobs. Default to 9.
18+
export CMAKE_BUILD_PARALLEL_LEVEL="${CMAKE_BUILD_PARALLEL_LEVEL:-9}"
19+
20+
main() {
21+
cd "${EXECUTORCH_ROOT}"
22+
23+
rm -rf cmake-out
24+
CXXFLAGS="-fno-exceptions -fno-rtti" cmake -DCMAKE_INSTALL_PREFIX=cmake-out \
25+
-DCMAKE_BUILD_TYPE=Release \
26+
-DEXECUTORCH_BUILD_DEVTOOLS=ON \
27+
-DEXECUTORCH_ENABLE_EVENT_TRACER=ON \
28+
-DEXECUTORCH_ENABLE_LOGGING=ON \
29+
-Bcmake-out .
30+
cmake --build cmake-out --target install --config Release -j16
31+
32+
local example_dir=backends/cadence
33+
local build_dir="cmake-out/${example_dir}"
34+
local cmake_prefix_path="${PWD}/cmake-out/lib/cmake/ExecuTorch;${PWD}/cmake-out/third-party/gflags"
35+
rm -rf ${build_dir}
36+
CXXFLAGS="-fno-exceptions -fno-rtti" cmake -DCMAKE_PREFIX_PATH="${cmake_prefix_path}" \
37+
-DCMAKE_BUILD_TYPE=Release \
38+
-DEXECUTORCH_CADENCE_CPU_RUNNER=ON \
39+
-DEXECUTORCH_ENABLE_LOGGING=ON \
40+
-B"${build_dir}" \
41+
"${example_dir}"
42+
cmake --build "${build_dir}" --config Release -j16
43+
44+
local runner="${PWD}/${build_dir}/cadence_runner"
45+
if [[ ! -f "${runner}" ]]; then
46+
echo "ERROR: Failed to build ${build_dir}/cadence_runner" >&2
47+
exit 1
48+
else
49+
echo "Built ${build_dir}/cadence_runner"
50+
fi
51+
}
52+
53+
main "$@"
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: cadence-build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- release/*
8+
pull_request:
9+
paths:
10+
# - .ci/scripts/setup-cadence.sh
11+
- .github/workflows/apple.yml
12+
- install_executorch.sh
13+
- backends/cadence/**
14+
- examples/cadence/**
15+
workflow_dispatch:
16+
schedule:
17+
- cron: '0 10 * * *' # Runs daily at 2 AM PST
18+
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}-${{ github.event_name == 'schedule' }}
21+
cancel-in-progress: true
22+
23+
jobs:
24+
setup-env:
25+
name: setup-env
26+
runs-on: ubuntu-22.04
27+
steps:
28+
- uses: actions/checkout@v3
29+
- name: Set up Python 3.10
30+
uses: actions/setup-python@v3
31+
with:
32+
python-version: "3.10"
33+
34+
set-envir-vars:
35+
name: set-envir-vars
36+
runs-on: ubuntu-22.04
37+
needs: setup-env
38+
outputs:
39+
version: ${{ steps.set_version.outputs.version }}
40+
steps:
41+
- name: Set VERSION variable
42+
id: set_version
43+
shell: bash
44+
run: |
45+
VERSION="0.5.0.$(TZ='PST8PDT' date +%Y%m%d)"
46+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
47+
48+
cpu-build:
49+
name: cpu-build
50+
needs: set-envir-vars
51+
# uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
52+
# secrets: inherit
53+
steps:
54+
- name: install executorch
55+
shell: bash
56+
run: |
57+
BUILD_TOOL="cmake"
58+
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
59+
- name: run cadence cpu build script
60+
shell: bash
61+
run: |
62+
.ci/scripts/build_cadence_runner.sh
63+
64+
g3-build:
65+
# NB: Don't run this on fork PRs because they won't have access to the secret and would fail anyway
66+
if: ${{ !github.event.pull_request.head.repo.fork }}
67+
runs-on: ubuntu-22.04
68+
hifi-build:
69+
# NB: Don't run this on fork PRs because they won't have access to the secret and would fail anyway
70+
if: ${{ !github.event.pull_request.head.repo.fork }}
71+
runs-on: ubuntu-22.04
72+
mv130-build:
73+
# NB: Don't run this on fork PRs because they won't have access to the secret and would fail anyway
74+
if: ${{ !github.event.pull_request.head.repo.fork }}
75+
runs-on: ubuntu-22.04
76+
hifi-build:
77+
# NB: Don't run this on fork PRs because they won't have access to the secret and would fail anyway
78+
if: ${{ !github.event.pull_request.head.repo.fork }}
79+
runs-on: ubuntu-22.04
80+
# uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
81+
# secrets: inherit
82+
with:
83+
runner: linux.2xlarge
84+
docker-image: executorch-ubuntu-22.04-cadence-sdk
85+
fetch-depth: 0
86+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
87+
timeout: 90

.github/workflows/docker-builds.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ jobs:
3838
- docker-image-name: executorch-ubuntu-22.04-linter
3939
- docker-image-name: executorch-ubuntu-22.04-arm-sdk
4040
- docker-image-name: executorch-ubuntu-22.04-qnn-sdk
41+
- docker-image-name: executorch-ubuntu-22.04-cadence-sdk
4142
- docker-image-name: executorch-ubuntu-22.04-mediatek-sdk
4243
- docker-image-name: executorch-ubuntu-22.04-clang12-android
4344
env:

0 commit comments

Comments
 (0)