Skip to content

Commit 1998177

Browse files
kirklandsignfacebook-github-bot
authored andcommitted
Run XNNPACK on single workflow (#1071)
Summary: Run XNNPACK (delegation-only, quantization-only, delegation+quantization) on a single workflow to save the number of jobs. Pull Request resolved: #1071 Reviewed By: huydhn Differential Revision: D50580091 Pulled By: kirklandsign fbshipit-source-id: 6b750a818497cb42739b91492fa137b7d1518e64
1 parent cc1a8bd commit 1998177

File tree

4 files changed

+39
-41
lines changed

4 files changed

+39
-41
lines changed

.ci/scripts/gather_test_models.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -93,32 +93,30 @@ def export_models_for_ci() -> dict[str, dict]:
9393
# This is the JSON syntax for configuration matrix used by GitHub
9494
# https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
9595
models = {"include": []}
96-
for (name, build_tool, q_config, d_config) in itertools.product(
97-
MODEL_NAME_TO_MODEL.keys(), BUILD_TOOLS.keys(), [False, True], [False, True]
96+
backends = ["portable", "xnnpack"]
97+
for (name, build_tool, backend) in itertools.product(
98+
MODEL_NAME_TO_MODEL.keys(), BUILD_TOOLS.keys(), backends
9899
):
99100
if not model_should_run_on_event(name, event):
100101
continue
101102

102-
if q_config and (
103-
(name not in MODEL_NAME_TO_OPTIONS)
104-
or (not MODEL_NAME_TO_OPTIONS[name].quantization)
105-
):
106-
continue
103+
if backend == "xnnpack":
104+
if (
105+
name in MODEL_NAME_TO_OPTIONS
106+
and MODEL_NAME_TO_OPTIONS[name].quantization
107+
):
108+
backend += "-quantization"
107109

108-
if d_config and (
109-
(name not in MODEL_NAME_TO_OPTIONS)
110-
or (not MODEL_NAME_TO_OPTIONS[name].delegation)
111-
):
112-
continue
110+
if name in MODEL_NAME_TO_OPTIONS and MODEL_NAME_TO_OPTIONS[name].delegation:
111+
backend += "-delegation"
113112

114113
if target_os not in BUILD_TOOLS[build_tool]:
115114
continue
116115

117116
record = {
118117
"build-tool": build_tool,
119118
"model": name,
120-
"xnnpack_quantization": q_config,
121-
"xnnpack_delegation": d_config,
119+
"backend": backend,
122120
"runner": DEFAULT_RUNNERS.get(target_os, "linux.2xlarge"),
123121
# demo_backend_delegation test only supports add_mul model
124122
"demo_backend_delegation": name == "add_mul",

.ci/scripts/test.sh

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,13 @@ if [[ -z "${BUILD_TOOL:-}" ]]; then
2222
exit 1
2323
fi
2424

25-
XNNPACK_QUANTIZATION=$3
26-
if [[ -z "${XNNPACK_QUANTIZATION:-}" ]]; then
27-
XNNPACK_QUANTIZATION=false
28-
fi
29-
30-
XNNPACK_DELEGATION=$4
31-
if [[ -z "${XNNPACK_DELEGATION:-}" ]]; then
32-
XNNPACK_DELEGATION=false
25+
BACKEND=$3
26+
if [[ -z "${BACKEND:-}" ]]; then
27+
echo "Missing backend (require portable or xnnpack), exiting..."
28+
exit 1
3329
fi
3430

35-
DEMO_BACKEND_DELEGATION=$5
31+
DEMO_BACKEND_DELEGATION=$4
3632
if [[ -z "${DEMO_BACKEND_DELEGATION:-}" ]]; then
3733
DEMO_BACKEND_DELEGATION=false
3834
fi
@@ -99,7 +95,7 @@ test_model_with_xnnpack() {
9995
# Quantization-only
10096
if [[ ${WITH_QUANTIZATION} == true ]] && [[ ${WITH_DELEGATION} == false ]]; then
10197
bash examples/xnnpack/quantization/test_quantize.sh "${BUILD_TOOL}" "${MODEL_NAME}"
102-
exit 0
98+
return 0
10399
fi
104100

105101
# Delegation
@@ -151,12 +147,25 @@ test_demo_backend_delegation() {
151147
fi
152148
}
153149

154-
if [[ "${XNNPACK_DELEGATION}" == false ]] && [[ "${XNNPACK_QUANTIZATION}" == false ]]; then
150+
if [[ "${BACKEND}" == "portable" ]]; then
155151
echo "Testing ${MODEL_NAME} with portable kernels..."
156152
test_model
157153
else
158-
echo "Testing ${MODEL_NAME} with XNNPACK quantization=${XNNPACK_QUANTIZATION} delegation=${XNNPACK_DELEGATION}..."
159-
test_model_with_xnnpack "${XNNPACK_QUANTIZATION}" "${XNNPACK_DELEGATION}"
154+
if [[ "${BACKEND}" == *"quantization"* ]]; then
155+
echo "::group::Testing ${MODEL_NAME} with XNNPACK quantization only..."
156+
test_model_with_xnnpack true false
157+
echo "::endgroup::"
158+
fi
159+
if [[ "${BACKEND}" == *"delegation"* ]]; then
160+
echo "::group::Testing ${MODEL_NAME} with XNNPACK delegation only..."
161+
test_model_with_xnnpack false true
162+
echo "::endgroup::"
163+
fi
164+
if [[ "${BACKEND}" == *"quantization"* ]] && [[ "${BACKEND}" == *"delegation"* ]]; then
165+
echo "::group::Testing ${MODEL_NAME} with XNNPACK quantization and delegation..."
166+
test_model_with_xnnpack true true
167+
echo "::endgroup::"
168+
fi
160169
fi
161170

162171
# Test demo backend delegation

.github/workflows/pull.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,12 @@ jobs:
5151
5252
MODEL_NAME=${{ matrix.model }}
5353
BUILD_TOOL=${{ matrix.build-tool }}
54-
XNNPACK_QUANTIZATION=${{ matrix.xnnpack_quantization }}
55-
XNNPACK_DELEGATION=${{ matrix.delegation }}
54+
BACKEND=${{ matrix.backend }}
5655
DEMO_BACKEND_DELEGATION=${{ matrix.demo_backend_delegation }}
5756
5857
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
5958
# Build and test ExecuTorch
60-
PYTHON_EXECUTABLE=python bash .ci/scripts/test.sh "${MODEL_NAME}" "${BUILD_TOOL}" "${XNNPACK_QUANTIZATION}" "${XNNPACK_DELEGATION}" "${DEMO_BACKEND_DELEGATION}"
59+
PYTHON_EXECUTABLE=python bash .ci/scripts/test.sh "${MODEL_NAME}" "${BUILD_TOOL}" "${BACKEND}" "${DEMO_BACKEND_DELEGATION}"
6160
6261
test-custom-ops-linux:
6362
name: test-custom-ops-linux

.github/workflows/trunk.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,15 @@ jobs:
2121
steps:
2222
- uses: actions/checkout@v3
2323
with:
24-
submodules: 'true'
24+
submodules: 'false'
2525
- uses: actions/setup-python@v4
2626
with:
2727
python-version: '3.10'
28-
cache: pip
2928
- name: Extract the list of models to test
3029
id: gather-models
3130
run: |
3231
set -eux
3332
34-
source .ci/scripts/utils.sh
35-
# This is a simple Python script but as it tries to import executorch.examples.models,
36-
# it requires a whole bunch of ExecuTorch dependencies on the Docker image
37-
install_pip_dependencies
38-
install_executorch
39-
4033
PYTHONPATH="${PWD}" python .ci/scripts/gather_test_models.py --target-os macos --event "${GITHUB_EVENT_NAME}"
4134
4235
test-models-macos:
@@ -57,14 +50,13 @@ jobs:
5750
5851
MODEL_NAME=${{ matrix.model }}
5952
BUILD_TOOL=${{ matrix.build-tool }}
60-
XNNPACK_QUANTIZATION=${{ matrix.xnnpack_quantization }}
61-
XNNPACK_DELEGATION=${{ matrix.delegation }}
53+
BACKEND=${{ matrix.backend }}
6254
DEMO_BACKEND_DELEGATION=${{ matrix.demo_backend_delegation }}
6355
6456
# Setup MacOS dependencies as there is no Docker support on MacOS atm
6557
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-macos.sh "${BUILD_TOOL}"
6658
# Build and test xecutorch
67-
PYTHON_EXECUTABLE=python bash .ci/scripts/test.sh "${MODEL_NAME}" "${BUILD_TOOL}" "${XNNPACK_QUANTIZATION}" "${XNNPACK_DELEGATION}" "${DEMO_BACKEND_DELEGATION}"
59+
PYTHON_EXECUTABLE=python bash .ci/scripts/test.sh "${MODEL_NAME}" "${BUILD_TOOL}" "${BACKEND}" "${DEMO_BACKEND_DELEGATION}"
6860
popd
6961
7062
test-custom-ops-macos:

0 commit comments

Comments
 (0)