Skip to content

Commit 7cbe7a1

Browse files
committed
Update
[ghstack-poisoned]
2 parents f1ace77 + 1ce7ed7 commit 7cbe7a1

File tree

110 files changed

+1397
-726
lines changed

Some content is hidden

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

110 files changed

+1397
-726
lines changed

.ci/scripts/setup-linux.sh

Lines changed: 7 additions & 9 deletions
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

Lines changed: 7 additions & 9 deletions
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-linux.sh

Lines changed: 5 additions & 16 deletions
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

Lines changed: 4 additions & 15 deletions
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

Lines changed: 50 additions & 5 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 6 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -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

.github/workflows/apple.yml

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
7070
# Setup MacOS dependencies as there is no Docker support on MacOS atm
7171
GITHUB_RUNNER=1 PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
72-
.ci/scripts/setup-macos.sh "${BUILD_TOOL}"
72+
.ci/scripts/setup-macos.sh --build-tool "${BUILD_TOOL}"
7373
7474
export ARTIFACTS_DIR_NAME=artifacts-to-be-uploaded
7575
@@ -160,7 +160,7 @@ jobs:
160160
161161
# Setup MacOS dependencies as there is no Docker support on MacOS atm
162162
GITHUB_RUNNER=1 PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
163-
.ci/scripts/setup-macos.sh "${BUILD_TOOL}"
163+
.ci/scripts/setup-macos.sh --build-tool "${BUILD_TOOL}"
164164
165165
# Install CoreML Backend Requirements
166166
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
@@ -293,7 +293,7 @@ jobs:
293293
BUILD_TOOL=cmake
294294
# Setup MacOS dependencies as there is no Docker support on MacOS atm
295295
GITHUB_RUNNER=1 PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
296-
.ci/scripts/setup-macos.sh "${BUILD_TOOL}"
296+
.ci/scripts/setup-macos.sh --build-tool "${BUILD_TOOL}"
297297
export ARTIFACTS_DIR_NAME=artifacts-to-be-uploaded
298298
299299
# Setup Apple certificate for iOS development
@@ -312,25 +312,8 @@ jobs:
312312
echo "::endgroup::"
313313
314314
echo "::group::Build ExecuTorch iOS frameworks"
315-
FRAMEWORKS=(
316-
"executorch"
317-
"backend_coreml"
318-
"backend_mps"
319-
"backend_xnnpack"
320-
"kernels_custom"
321-
"kernels_optimized"
322-
"kernels_portable"
323-
"kernels_quantized"
324-
)
325-
326-
# Build Release iOS Frameworks
327315
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
328-
build/build_apple_frameworks.sh --coreml --custom --mps --optimized --portable --quantized --xnnpack
329-
330-
mkdir -p extension/benchmark/apple/Benchmark/Frameworks
331-
for FRAMEWORK in "${FRAMEWORKS[@]}"; do (
332-
cp -r "cmake-out/${FRAMEWORK}.xcframework" extension/benchmark/apple/Benchmark/Frameworks/
333-
) done
316+
build/build_apple_frameworks.sh --Release --Debug --coreml --custom --mps --optimized --portable --quantized --xnnpack
334317
echo "::endgroup::"
335318
336319
echo "::group::Build ExecuTorch benchmark app"

.github/workflows/doc-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
3939
BUILD_TOOL=${{ matrix.build-tool }}
4040
# Setup dependencies as there is no Docker support
41-
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
41+
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh --build-tool "${BUILD_TOOL}"
4242
4343
if [[(${GITHUB_EVENT_NAME} = 'pull_request' && (${GITHUB_BASE_REF} = 'release'*)) || (${GITHUB_REF} = 'refs/heads/release'*) ]]; then
4444
export CHANNEL=test

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
# For mypy linting, we need to first install executorch first so that
3636
# it builds the python package information.
3737
BUILD_TOOL="cmake"
38-
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
38+
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh --build-tool "${BUILD_TOOL}"
3939
4040
CACHE_DIRECTORY="/tmp/.lintbin"
4141
# Try to recover the cached binaries

.github/workflows/periodic.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,6 @@ jobs:
6363
BACKEND=${{ matrix.backend }}
6464
DEMO_BACKEND_DELEGATION=${{ matrix.demo_backend_delegation }}
6565
66-
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
66+
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh --build-tool "${BUILD_TOOL}"
6767
# Build and test ExecuTorch
6868
PYTHON_EXECUTABLE=python bash .ci/scripts/test_model.sh "${MODEL_NAME}" "${BUILD_TOOL}" "${BACKEND}" "${DEMO_BACKEND_DELEGATION}"

0 commit comments

Comments
 (0)