Skip to content

Commit ffc39d8

Browse files
authored
Merge branch 'main' into jz/log-to-edge
2 parents 2c0fec9 + 160421a commit ffc39d8

File tree

194 files changed

+3323
-2040
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

194 files changed

+3323
-2040
lines changed

.buckconfig

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111
shim_et = shim_et
1212

1313
[repository_aliases]
14+
bazel_skylib = shim
1415
config = prelude
1516
ovr_config = prelude
1617
toolchains = shim_et
1718
fbcode = shim_et
18-
fbcode_macros = shim_et
19+
fbcode_macros = shim
1920
fbsource = shim_et
2021
buck = shim
22+
gh_facebook_buck2_shims_meta = shim
2123

2224
[cxx]
2325
cxxflags = -g -std=c++17

.ci/scripts/setup-linux.sh

+7-9
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,17 @@ set -exu
1010
# shellcheck source=/dev/null
1111
source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"
1212

13-
BUILD_TOOL=$1
14-
if [[ -z "${BUILD_TOOL:-}" ]]; then
15-
echo "Missing build tool (require buck2 or cmake), exiting..."
16-
exit 1
17-
else
18-
echo "Setup Linux for ${BUILD_TOOL} ..."
19-
fi
13+
read -r BUILD_TOOL BUILD_MODE EDITABLE < <(parse_args "$@")
2014

2115
# As Linux job is running inside a Docker container, all of its dependencies
2216
# have already been installed, so we use PyTorch build from source here instead
2317
# of nightly. This allows CI to test against latest commits from PyTorch
24-
install_executorch "use-pt-pinned-commit"
25-
build_executorch_runner "${BUILD_TOOL}" "${2:-Release}"
18+
if [[ "${EDITABLE:-false}" == "true" ]]; then
19+
install_executorch --use-pt-pinned-commit --editable
20+
else
21+
install_executorch --use-pt-pinned-commit
22+
fi
23+
build_executorch_runner "${BUILD_TOOL}" "${BUILD_MODE}"
2624

2725
if [[ "${GITHUB_BASE_REF:-}" == *main* || "${GITHUB_BASE_REF:-}" == *gh* ]]; then
2826
do_not_use_nightly_on_ci

.ci/scripts/setup-macos.sh

+7-9
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,7 @@ set -exu
1010
# shellcheck source=/dev/null
1111
source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"
1212

13-
BUILD_TOOL=$1
14-
if [[ -z "${BUILD_TOOL:-}" ]]; then
15-
echo "Missing build tool (require buck2 or cmake), exiting..."
16-
exit 1
17-
else
18-
echo "Setup MacOS for ${BUILD_TOOL} ..."
19-
fi
13+
read -r BUILD_TOOL BUILD_MODE EDITABLE < <(parse_args "$@")
2014

2115
install_buck() {
2216
if ! command -v zstd &> /dev/null; then
@@ -135,8 +129,12 @@ print_cmake_info
135129
install_pytorch_and_domains
136130
# We build PyTorch from source here instead of using nightly. This allows CI to test against
137131
# the pinned commit from PyTorch
138-
install_executorch "use-pt-pinned-commit"
139-
build_executorch_runner "${BUILD_TOOL}" "${2:-Release}"
132+
if [[ "$EDITABLE" == "true" ]]; then
133+
install_executorch --use-pt-pinned-commit --editable
134+
else
135+
install_executorch --use-pt-pinned-commit
136+
fi
137+
build_executorch_runner "${BUILD_TOOL}" "${BUILD_MODE}"
140138

141139
if [[ "${GITHUB_BASE_REF:-}" == *main* || "${GITHUB_BASE_REF:-}" == *gh* ]]; then
142140
do_not_use_nightly_on_ci

.ci/scripts/unittest-buck2.sh

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
set -eux
88

99
# TODO: expand this to //...
10-
buck2 query //runtime/...
10+
# TODO: can't query cadence & vulkan backends
11+
buck2 query "//backends/apple/... + //backends/example/... + \
12+
//backends/mediatek/... + //backends/test/... + //backends/transforms/... + \
13+
//backends/xnnpack/... + //configurations/... + //kernels/portable/cpu/... + \
14+
//runtime/... + //schema/... + //test/... + //util/..."
1115

1216
# TODO: expand the covered scope of Buck targets.
1317
buck2 build //runtime/core/portable_type/...

.ci/scripts/unittest-linux.sh

+5-16
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,10 @@
66
# LICENSE file in the root directory of this source tree.
77
set -eux
88

9-
BUILD_TOOL=$1
10-
if [[ $BUILD_TOOL =~ ^(cmake|buck2)$ ]]; then
11-
echo "Running unittests for ${BUILD_TOOL} ..."
12-
else
13-
echo "Missing build tool (require buck2 or cmake), exiting..."
14-
exit 1
15-
fi
9+
# shellcheck source=/dev/null
10+
source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"
1611

17-
BUILD_MODE=$2
18-
if [[ "${BUILD_MODE:-}" =~ ^(Debug|Release)$ ]]; then
19-
echo "Running tests in build mode ${BUILD_MODE} ..."
20-
else
21-
echo "Unsupported build mode ${BUILD_MODE}, options are Debug or Release."
22-
exit 1
23-
fi
12+
read -r BUILD_TOOL BUILD_MODE EDITABLE < <(parse_args "$@")
2413

2514
# The generic Linux job chooses to use base env, not the one setup by the image
2615
eval "$(conda shell.bash hook)"
@@ -34,7 +23,7 @@ if [[ "$BUILD_TOOL" == "cmake" ]]; then
3423
PYTHON_EXECUTABLE=python \
3524
EXECUTORCH_BUILD_PYBIND=ON \
3625
CMAKE_ARGS="-DEXECUTORCH_BUILD_XNNPACK=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON" \
37-
.ci/scripts/setup-linux.sh "$BUILD_TOOL" "$BUILD_MODE"
26+
.ci/scripts/setup-linux.sh "$@"
3827

3928
# Install llama3_2_vision dependencies.
4029
PYTHON_EXECUTABLE=python ./examples/models/llama3_2_vision/install_requirements.sh
@@ -45,7 +34,7 @@ elif [[ "$BUILD_TOOL" == "buck2" ]]; then
4534
# because TMPDIR gets messed up? Please feel free to fix this and
4635
# speed up this CI job!
4736
PYTHON_EXECUTABLE=python \
48-
.ci/scripts/setup-linux.sh "$BUILD_TOOL" "$BUILD_MODE"
37+
.ci/scripts/setup-linux.sh "$@"
4938

5039
.ci/scripts/unittest-buck2.sh
5140
else

.ci/scripts/unittest-macos.sh

+4-15
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,10 @@
66
# LICENSE file in the root directory of this source tree.
77
set -eux
88

9-
BUILD_TOOL=$1
10-
if [[ $BUILD_TOOL =~ ^(cmake|buck2)$ ]]; then
11-
echo "Running unittests for ${BUILD_TOOL} ..."
12-
else
13-
echo "Missing build tool (require buck2 or cmake), exiting..."
14-
exit 1
15-
fi
9+
# shellcheck source=/dev/null
10+
source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"
1611

17-
BUILD_MODE=$2
18-
if [[ $BUILD_MODE =~ ^(Debug|Release)$ ]]; then
19-
echo "Running tests in build mode ${BUILD_MODE} ..."
20-
else
21-
echo "Unsupported build mode ${BUILD_MODE}, options are Debug or Release."
22-
exit 1
23-
fi
12+
read -r BUILD_TOOL BUILD_MODE EDITABLE < <(parse_args "$@")
2413

2514
bash .ci/scripts/setup-conda.sh
2615
eval "$(conda shell.bash hook)"
@@ -36,7 +25,7 @@ if [[ "$BUILD_TOOL" == "cmake" ]]; then
3625
EXECUTORCH_BUILD_PYBIND=ON \
3726
CMAKE_ARGS="-DEXECUTORCH_BUILD_COREML=ON -DEXECUTORCH_BUILD_MPS=ON -DEXECUTORCH_BUILD_XNNPACK=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON" \
3827
${CONDA_RUN} --no-capture-output \
39-
.ci/scripts/setup-macos.sh "${BUILD_TOOL}" "${BUILD_MODE}"
28+
.ci/scripts/setup-macos.sh "$@"
4029

4130
# Install llama3_2_vision dependencies.
4231
PYTHON_EXECUTABLE=python \

.ci/scripts/utils.sh

+50-5
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@ install_executorch() {
2424
which pip
2525
# Install executorch, this assumes that Executorch is checked out in the
2626
# current directory.
27-
if [[ "${1:-}" == "use-pt-pinned-commit" ]]; then
28-
./install_executorch.sh --pybind xnnpack --use-pt-pinned-commit
29-
else
30-
./install_executorch.sh --pybind xnnpack
31-
fi
27+
./install_executorch.sh --pybind xnnpack "$@"
3228
# Just print out the list of packages for debugging
3329
pip list
3430
}
@@ -166,3 +162,52 @@ do_not_use_nightly_on_ci() {
166162
exit 1
167163
fi
168164
}
165+
166+
167+
parse_args() {
168+
local args=("$@")
169+
local i
170+
local BUILD_TOOL=""
171+
local BUILD_MODE=""
172+
local EDITABLE=""
173+
for ((i=0; i<${#args[@]}; i++)); do
174+
case "${args[$i]}" in
175+
--build-tool)
176+
BUILD_TOOL="${args[$((i+1))]}"
177+
i=$((i+1))
178+
;;
179+
--build-mode)
180+
BUILD_MODE="${args[$((i+1))]}"
181+
i=$((i+1))
182+
;;
183+
--editable)
184+
EDITABLE="${args[$((i+1))]}"
185+
i=$((i+1))
186+
;;
187+
*)
188+
echo "Invalid argument: ${args[$i]}"
189+
exit 1
190+
;;
191+
esac
192+
done
193+
194+
if [ -z "$BUILD_TOOL" ]; then
195+
echo "Missing build tool (require buck2 or cmake), exiting..."
196+
exit 1
197+
elif ! [[ $BUILD_TOOL =~ ^(cmake|buck2)$ ]]; then
198+
echo "Require buck2 or cmake for --build-tool, got ${BUILD_TOOL}, exiting..."
199+
exit 1
200+
fi
201+
BUILD_MODE="${BUILD_MODE:-Release}"
202+
if ! [[ "$BUILD_MODE" =~ ^(Debug|Release)$ ]]; then
203+
echo "Unsupported build mode ${BUILD_MODE}, options are Debug or Release."
204+
exit 1
205+
fi
206+
EDITABLE="${EDITABLE:-false}"
207+
if ! [[ $EDITABLE =~ ^(true|false)$ ]]; then
208+
echo "Require true or false for --editable, got ${EDITABLE}, exiting..."
209+
exit 1
210+
fi
211+
212+
echo "$BUILD_TOOL $BUILD_MODE $EDITABLE"
213+
}

.github/workflows/_android.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
# The generic Linux job chooses to use base env, not the one setup by the image
2626
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
2727
conda activate "${CONDA_ENV}"
28-
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh buck2
28+
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh --build-tool buck2
2929
export ARTIFACTS_DIR_NAME=artifacts-to-be-uploaded
3030
3131
# Build LLM Demo for Android

.github/workflows/_unittest.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ on:
1515
required: true
1616
type: string
1717
description: Build tool to use, cmake or buck2.
18+
editable:
19+
required: false
20+
type: string
21+
description: Install ExecuTorch in editable mode or not.
1822
python-version:
1923
required: false
2024
type: string
@@ -34,7 +38,7 @@ jobs:
3438
timeout: 90
3539
script: |
3640
set -eux
37-
.ci/scripts/unittest-linux.sh "${{ inputs.build-tool }}" "${{ inputs.build-mode }}"
41+
.ci/scripts/unittest-linux.sh --build-tool "${{ inputs.build-tool }}" --build-mode "${{ inputs.build-mode }}" --editable "${{ inputs.editable }}"
3842
3943
macos:
4044
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
@@ -45,4 +49,4 @@ jobs:
4549
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
4650
script: |
4751
set -eux
48-
.ci/scripts/unittest-macos.sh "${{ inputs.build-tool }}" "${{ inputs.build-mode }}"
52+
.ci/scripts/unittest-macos.sh --build-tool "${{ inputs.build-tool }}" --build-mode "${{ inputs.build-mode }}" --editable "${{ inputs.editable }}"

.github/workflows/android-perf.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ on:
2020
description: Models to be benchmarked
2121
required: false
2222
type: string
23-
default: stories110M
23+
default: llama
2424
devices:
2525
description: Target devices to run benchmark
2626
required: false
@@ -36,7 +36,7 @@ on:
3636
description: Models to be benchmarked
3737
required: false
3838
type: string
39-
default: stories110M
39+
default: llama
4040
devices:
4141
description: Target devices to run benchmark
4242
required: false
@@ -181,7 +181,7 @@ jobs:
181181
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-qnn-deps.sh
182182
PYTHON_EXECUTABLE=python bash .ci/scripts/build-qnn-sdk.sh
183183
fi
184-
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "cmake"
184+
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh --build-tool "cmake"
185185
# Install requirements for export_llama
186186
PYTHON_EXECUTABLE=python bash examples/models/llama/install_requirements.sh
187187
@@ -356,7 +356,7 @@ jobs:
356356
# The generic Linux job chooses to use base env, not the one setup by the image
357357
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
358358
conda activate "${CONDA_ENV}"
359-
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh cmake
359+
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh --build-tool cmake
360360
export ARTIFACTS_DIR_NAME=artifacts-to-be-uploaded
361361
362362
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-qnn-deps.sh

.github/workflows/android-release-artifacts.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
# The generic Linux job chooses to use base env, not the one setup by the image
5050
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
5151
conda activate "${CONDA_ENV}"
52-
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh buck2
52+
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh --build-tool buck2
5353
export ARTIFACTS_DIR_NAME=artifacts-to-be-uploaded
5454
5555
# Build LLM Demo for Android

.github/workflows/apple-perf.yml

+5-22
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ on:
2020
description: Models to be benchmarked
2121
required: false
2222
type: string
23-
default: stories110M
23+
default: llama
2424
devices:
2525
description: Target devices to run benchmark
2626
required: false
@@ -36,7 +36,7 @@ on:
3636
description: Models to be benchmarked
3737
required: false
3838
type: string
39-
default: stories110M
39+
default: llama
4040
devices:
4141
description: Target devices to run benchmark
4242
required: false
@@ -181,7 +181,7 @@ jobs:
181181
BUILD_TOOL=cmake
182182
# Setup MacOS dependencies as there is no Docker support on MacOS atm
183183
GITHUB_RUNNER=1 PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
184-
.ci/scripts/setup-macos.sh "${BUILD_TOOL}"
184+
.ci/scripts/setup-macos.sh --build-tool "${BUILD_TOOL}"
185185
186186
if [[ ${{ matrix.config }} == *"coreml"* ]]; then
187187
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
@@ -367,7 +367,7 @@ jobs:
367367
BUILD_TOOL=cmake
368368
# Setup MacOS dependencies as there is no Docker support on MacOS atm
369369
GITHUB_RUNNER=1 PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
370-
.ci/scripts/setup-macos.sh "${BUILD_TOOL}"
370+
.ci/scripts/setup-macos.sh --build-tool "${BUILD_TOOL}"
371371
export ARTIFACTS_DIR_NAME=artifacts-to-be-uploaded
372372
373373
# Setup Apple certificate for iOS development
@@ -386,25 +386,8 @@ jobs:
386386
echo "::endgroup::"
387387
388388
echo "::group::Build ExecuTorch iOS frameworks"
389-
FRAMEWORKS=(
390-
"executorch"
391-
"backend_coreml"
392-
"backend_mps"
393-
"backend_xnnpack"
394-
"kernels_custom"
395-
"kernels_optimized"
396-
"kernels_portable"
397-
"kernels_quantized"
398-
)
399-
400-
# Build Release iOS Frameworks
401389
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
402-
build/build_apple_frameworks.sh --coreml --custom --mps --optimized --portable --quantized --xnnpack
403-
404-
mkdir -p extension/benchmark/apple/Benchmark/Frameworks
405-
for FRAMEWORK in "${FRAMEWORKS[@]}"; do (
406-
cp -r "cmake-out/${FRAMEWORK}.xcframework" extension/benchmark/apple/Benchmark/Frameworks/
407-
) done
390+
build/build_apple_frameworks.sh --Release --Debug --coreml --custom --mps --optimized --portable --quantized --xnnpack
408391
echo "::endgroup::"
409392
410393
# NB: Although exported models can be copied to this directory and bundled together with the

0 commit comments

Comments
 (0)