Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Zonglin Peng committed Feb 23, 2025
1 parent 366d87e commit 9ddcaf5
Show file tree
Hide file tree
Showing 8 changed files with 347 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .ci/docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ case "${IMAGE_NAME}" in
QNN_SDK=yes
CLANG_VERSION=12
;;
executorch-ubuntu-22.04-cadence-sdk)
CADENCE_SDK=yes
CLANG_VERSION=12
;;
executorch-ubuntu-22.04-mediatek-sdk)
MEDIATEK_SDK=yes
CLANG_VERSION=12
Expand Down Expand Up @@ -81,6 +85,7 @@ docker build \
--build-arg "BUILD_DOCS=${BUILD_DOCS}" \
--build-arg "ARM_SDK=${ARM_SDK:-}" \
--build-arg "QNN_SDK=${QNN_SDK:-}" \
--build-arg "CADENCE_SDK=${CADENCE_SDK:-}" \
--build-arg "MEDIATEK_SDK=${MEDIATEK_SDK:-}" \
--build-arg "ANDROID_NDK_VERSION=${ANDROID_NDK_VERSION:-}" \
-f "${OS}"/Dockerfile \
Expand Down
12 changes: 12 additions & 0 deletions .ci/docker/common/install_cadence.sh
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}" ]
7 changes: 7 additions & 0 deletions .ci/docker/ubuntu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ ARG ARM_SDK

ARG QNN_SDK

ARG CADENCE_SDK
# Install cadence if needed
COPY ./common/install_cadence.sh install_cadence.sh
RUN if [ -n "${CADENCE_SDK}" ]; then bash ./install_cadence.sh; fi
RUN rm install_cadence.sh


ARG MEDIATEK_SDK

USER ci-user
Expand Down
92 changes: 92 additions & 0 deletions .ci/scripts/build_cadence_fusionG3.sh
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
90 changes: 90 additions & 0 deletions .ci/scripts/build_cadence_hifi4.sh
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
53 changes: 53 additions & 0 deletions .ci/scripts/build_cadence_runner.sh
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 "$@"
87 changes: 87 additions & 0 deletions .github/workflows/cadence-build.yml
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
1 change: 1 addition & 0 deletions .github/workflows/docker-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
- docker-image-name: executorch-ubuntu-22.04-linter
- docker-image-name: executorch-ubuntu-22.04-arm-sdk
- docker-image-name: executorch-ubuntu-22.04-qnn-sdk
- docker-image-name: executorch-ubuntu-22.04-cadence-sdk
- docker-image-name: executorch-ubuntu-22.04-mediatek-sdk
- docker-image-name: executorch-ubuntu-22.04-clang12-android
env:
Expand Down

0 comments on commit 9ddcaf5

Please sign in to comment.