Skip to content

Commit 2df919e

Browse files
guangy10facebook-github-bot
authored andcommitted
Decouple model e2e tests
Differential Revision: D49622665
1 parent 13bac84 commit 2df919e

File tree

3 files changed

+41
-42
lines changed

3 files changed

+41
-42
lines changed

.ci/scripts/gather_test_models.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,27 @@ def export_models_for_ci() -> None:
4949
# https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
5050
models = {"include": []}
5151
for name in MODEL_NAME_TO_MODEL.keys():
52-
quantization = (
53-
name in MODEL_NAME_TO_OPTIONS and MODEL_NAME_TO_OPTIONS[name].quantization
54-
)
55-
xnnpack_delegation = (
52+
quantization_configs = {
53+
False,
54+
name in MODEL_NAME_TO_OPTIONS and MODEL_NAME_TO_OPTIONS[name].quantization,
55+
}
56+
delegation_configs = {
57+
False,
5658
name in MODEL_NAME_TO_OPTIONS
57-
and MODEL_NAME_TO_OPTIONS[name].xnnpack_delegation
58-
)
59+
and MODEL_NAME_TO_OPTIONS[name].xnnpack_delegation,
60+
}
5961
for build_tool in BUILD_TOOLS:
60-
models["include"].append(
61-
{
62-
"build-tool": build_tool,
63-
"model": name,
64-
"quantization": quantization,
65-
"xnnpack_delegation": xnnpack_delegation,
66-
"runner": RUNNERS.get(name, DEFAULT_RUNNER),
67-
}
68-
)
62+
for q_config in quantization_configs:
63+
for d_config in delegation_configs:
64+
models["include"].append(
65+
{
66+
"build-tool": build_tool,
67+
"model": name,
68+
"xnnpack_quantization": q_config,
69+
"xnnpack_delegation": d_config,
70+
"runner": RUNNERS.get(name, DEFAULT_RUNNER),
71+
}
72+
)
6973
set_output("models", json.dumps(models))
7074

7175

.ci/scripts/test.sh

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

25-
QUANTIZATION=$3
26-
if [[ -z "${QUANTIZATION:-}" ]]; then
27-
QUANTIZATION=false
25+
XNNPACK_QUANTIZATION=$3
26+
if [[ -z "${XNNPACK_QUANTIZATION:-}" ]]; then
27+
XNNPACK_QUANTIZATION=false
2828
fi
2929

3030
XNNPACK_DELEGATION=$4
@@ -83,6 +83,15 @@ build_cmake_xnn_executor_runner() {
8383

8484
test_model_with_xnnpack() {
8585
WITH_QUANTIZATION=$1
86+
WITH_DELEGATION=$2
87+
88+
# Quantization-only
89+
if [[ ${WITH_QUANTIZATION} == true ]] && [[ ${WITH_DELEGATION=$2} == false ]]; then
90+
bash examples/quantization/test_quantize.sh "${BUILD_TOOL}" "${MODEL_NAME}"
91+
exit 0
92+
fi
93+
94+
# Delegation
8695
if [[ ${WITH_QUANTIZATION} == true ]]; then
8796
SUFFIX="q8"
8897
"${PYTHON_EXECUTABLE}" -m examples.backend.xnnpack_examples --model_name="${MODEL_NAME}" --delegate --quantize
@@ -92,6 +101,7 @@ test_model_with_xnnpack() {
92101
fi
93102

94103
OUTPUT_MODEL_PATH="${MODEL_NAME}_xnnpack_${SUFFIX}.pte"
104+
95105
# Run test model
96106
if [[ "${BUILD_TOOL}" == "buck2" ]]; then
97107
buck2 run //examples/backend:xnn_executor_runner -- --model_path "${OUTPUT_MODEL_PATH}"
@@ -106,25 +116,10 @@ test_model_with_xnnpack() {
106116
fi
107117
}
108118

109-
echo "Testing ${MODEL_NAME} (fp32, quantized, xnnpack) with ${BUILD_TOOL}..."
110-
# Test the select model without XNNPACK or quantization
111-
test_model
112-
113-
# Test quantization
114-
if [[ "${QUANTIZATION}" == true ]]; then
115-
bash examples/quantization/test_quantize.sh "${BUILD_TOOL}" "${MODEL_NAME}"
119+
if [[ "${XNNPACK_DELEGATION}" == false ]] && [[ "${XNNPACK_QUANTIZATION}" == false ]]; then
120+
echo "Testing ${MODEL_NAME} with portable kernels..."
121+
test_model
116122
else
117-
echo "The model ${MODEL_NAME} doesn't support quantization yet"
118-
fi
119-
120-
# Test XNNPACK without quantization
121-
if [[ "${XNNPACK_DELEGATION}" == true ]]; then
122-
test_model_with_xnnpack false
123-
else
124-
echo "The model ${MODEL_NAME} doesn't support XNNPACK yet"
125-
fi
126-
127-
# Test XNNPACK with quantization
128-
if [[ "${XNNPACK_DELEGATION}" == true ]] && [[ "${QUANTIZATION}" == true ]]; then
129-
test_model_with_xnnpack true
123+
echo "Testing ${MODEL_NAME} with XNNPACK quantization=${XNNPACK_QUANTIZATION} delegation=${XNNPACK_DELEGATION}..."
124+
test_model_with_xnnpack "${XNNPACK_QUANTIZATION}" "${XNNPACK_DELEGATION}"
130125
fi

.github/workflows/pull.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ jobs:
5757
5858
MODEL_NAME=${{ matrix.model }}
5959
BUILD_TOOL=${{ matrix.build-tool }}
60-
QUANTIZATION=${{ matrix.quantization }}
60+
XNNPACK_QUANTIZATION=${{ matrix.xnnpack_quantization }}
6161
XNNPACK_DELEGATION=${{ matrix.xnnpack_delegation }}
6262
6363
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
6464
# Build and test Executorch
65-
PYTHON_EXECUTABLE=python bash .ci/scripts/test.sh "${MODEL_NAME}" "${BUILD_TOOL}" "${QUANTIZATION}" "${XNNPACK_DELEGATION}"
65+
PYTHON_EXECUTABLE=python bash .ci/scripts/test.sh "${MODEL_NAME}" "${BUILD_TOOL}" "${XNNPACK_QUANTIZATION}" "${XNNPACK_DELEGATION}"
6666
6767
test-models-macos:
6868
name: test-models-macos
@@ -82,13 +82,13 @@ jobs:
8282
8383
MODEL_NAME=${{ matrix.model }}
8484
BUILD_TOOL=${{ matrix.build-tool }}
85-
QUANTIZATION=${{ matrix.quantization }}
85+
XNNPACK_QUANTIZATION=${{ matrix.xnnpack_quantization }}
8686
XNNPACK_DELEGATION=${{ matrix.xnnpack_delegation }}
8787
8888
# Setup MacOS dependencies as there is no Docker support on MacOS atm
8989
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-macos.sh "${BUILD_TOOL}"
9090
# Build and test Executorch
91-
PYTHON_EXECUTABLE=python bash .ci/scripts/test.sh "${MODEL_NAME}" "${BUILD_TOOL}" "${QUANTIZATION}" "${XNNPACK_DELEGATION}"
91+
PYTHON_EXECUTABLE=python bash .ci/scripts/test.sh "${MODEL_NAME}" "${BUILD_TOOL}" "${XNNPACK_QUANTIZATION}" "${XNNPACK_DELEGATION}"
9292
popd
9393
9494
test-custom-ops-linux:

0 commit comments

Comments
 (0)