Skip to content

Commit 26e72e4

Browse files
authored
Add coreml models to CI and benchmark workflow
Differential Revision: D62323397 Pull Request resolved: #5150
1 parent 1511fc1 commit 26e72e4

File tree

6 files changed

+53
-8
lines changed

6 files changed

+53
-8
lines changed

.ci/scripts/test.sh renamed to .ci/scripts/test_model.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,16 @@ test_model_with_qnn() {
182182
EXPORTED_MODEL=./${EXPORT_SCRIPT}/${EXPORTED_MODEL_NAME}
183183
}
184184

185+
test_model_with_coreml() {
186+
if [[ "${BUILD_TOOL}" == "buck2" ]]; then
187+
echo "coreml doesn't support buck2."
188+
exit 1
189+
fi
190+
191+
"${PYTHON_EXECUTABLE}" -m examples.apple.coreml.scripts.export --model_name="${MODEL_NAME}"
192+
EXPORTED_MODEL=$(find "." -type f -name "${MODEL_NAME}*.pte" -print -quit)
193+
}
194+
185195
if [[ "${BACKEND}" == "portable" ]]; then
186196
echo "Testing ${MODEL_NAME} with portable kernels..."
187197
test_model
@@ -191,6 +201,12 @@ elif [[ "${BACKEND}" == "qnn" ]]; then
191201
if [[ $? -eq 0 ]]; then
192202
prepare_artifacts_upload
193203
fi
204+
elif [[ "${BACKEND}" == "coreml" ]]; then
205+
echo "Testing ${MODEL_NAME} with coreml..."
206+
test_model_with_coreml
207+
if [[ $? -eq 0 ]]; then
208+
prepare_artifacts_upload
209+
fi
194210
elif [[ "${BACKEND}" == "xnnpack" ]]; then
195211
echo "Testing ${MODEL_NAME} with xnnpack..."
196212
test_model_with_xnnpack true true

.github/workflows/android-perf.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ jobs:
170170
fi
171171
PYTHON_EXECUTABLE=python bash .ci/scripts/test_llama.sh "${{ matrix.model }}" "${BUILD_MODE}" "${DTYPE}" "${DELEGATE_CONFIG}" "${ARTIFACTS_DIR_NAME}"
172172
else
173-
PYTHON_EXECUTABLE=python bash .ci/scripts/test.sh "${{ matrix.model }}" "${BUILD_MODE}" "${{ matrix.delegate }}" "${ARTIFACTS_DIR_NAME}"
173+
PYTHON_EXECUTABLE=python bash .ci/scripts/test_model.sh "${{ matrix.model }}" "${BUILD_MODE}" "${{ matrix.delegate }}" "${ARTIFACTS_DIR_NAME}"
174174
fi
175175
echo "::endgroup::"
176176

.github/workflows/apple-perf.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,8 @@ jobs:
169169
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
170170
bash .ci/scripts/test_llama.sh "${{ matrix.model }}" "${BUILD_MODE}" "${DTYPE}" "${DELEGATE_CONFIG}" "${ARTIFACTS_DIR_NAME}"
171171
else
172-
# TODO (huydhn): Extend the export script here to support other backends such as coreml, mps
173172
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
174-
bash .ci/scripts/test.sh "${{ matrix.model }}" "${BUILD_MODE}" "${{ matrix.delegate }}" "${ARTIFACTS_DIR_NAME}"
173+
bash .ci/scripts/test_model.sh "${{ matrix.model }}" "${BUILD_MODE}" "${{ matrix.delegate }}" "${ARTIFACTS_DIR_NAME}"
175174
fi
176175
echo "::endgroup::"
177176

.github/workflows/periodic.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@ jobs:
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}" "${BACKEND}" "${DEMO_BACKEND_DELEGATION}"
65+
PYTHON_EXECUTABLE=python bash .ci/scripts/test_model.sh "${MODEL_NAME}" "${BUILD_TOOL}" "${BACKEND}" "${DEMO_BACKEND_DELEGATION}"

.github/workflows/pull.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
5555
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
5656
# Build and test ExecuTorch with the add model on portable backend.
57-
PYTHON_EXECUTABLE=python bash .ci/scripts/test.sh "add" "${BUILD_TOOL}" "portable"
57+
PYTHON_EXECUTABLE=python bash .ci/scripts/test_model.sh "add" "${BUILD_TOOL}" "portable"
5858
5959
test-models-linux:
6060
name: test-models-linux
@@ -81,7 +81,7 @@ jobs:
8181
8282
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
8383
# Build and test ExecuTorch
84-
PYTHON_EXECUTABLE=python bash .ci/scripts/test.sh "${MODEL_NAME}" "${BUILD_TOOL}" "${BACKEND}" "${DEMO_BACKEND_DELEGATION}"
84+
PYTHON_EXECUTABLE=python bash .ci/scripts/test_model.sh "${MODEL_NAME}" "${BUILD_TOOL}" "${BACKEND}" "${DEMO_BACKEND_DELEGATION}"
8585
8686
test-llama-runner-linux:
8787
name: test-llama-runner-linux

.github/workflows/trunk.yml

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
# Setup MacOS dependencies as there is no Docker support on MacOS atm
6060
PYTHON_EXECUTABLE=python ${CONDA_RUN} bash .ci/scripts/setup-macos.sh "${BUILD_TOOL}"
6161
# Build and test xecutorch
62-
PYTHON_EXECUTABLE=python ${CONDA_RUN} bash .ci/scripts/test.sh "${MODEL_NAME}" "${BUILD_TOOL}" "${BACKEND}" "${DEMO_BACKEND_DELEGATION}"
62+
PYTHON_EXECUTABLE=python ${CONDA_RUN} bash .ci/scripts/test_model.sh "${MODEL_NAME}" "${BUILD_TOOL}" "${BACKEND}" "${DEMO_BACKEND_DELEGATION}"
6363
6464
test-custom-ops-macos:
6565
name: test-custom-ops-macos
@@ -320,4 +320,34 @@ jobs:
320320
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh cmake
321321
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-qnn-deps.sh
322322
PYTHON_EXECUTABLE=python bash .ci/scripts/build-qnn-sdk.sh
323-
PYTHON_EXECUTABLE=python bash .ci/scripts/test.sh ${{ matrix.model }} "cmake" "qnn"
323+
PYTHON_EXECUTABLE=python bash .ci/scripts/test_model.sh ${{ matrix.model }} "cmake" "qnn"
324+
325+
test-coreml-model:
326+
name: test-coreml-model
327+
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
328+
strategy:
329+
fail-fast: false
330+
with:
331+
runner: macos-m1-stable
332+
python-version: '3.11'
333+
submodules: 'true'
334+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
335+
timeout: 90
336+
script: |
337+
BUILD_TOOL=cmake
338+
BACKEND=coreml
339+
340+
bash .ci/scripts/setup-conda.sh
341+
342+
# Setup MacOS dependencies as there is no Docker support on MacOS atm
343+
PYTHON_EXECUTABLE=python ${CONDA_RUN} bash .ci/scripts/setup-macos.sh "${BUILD_TOOL}"
344+
PYTHON_EXECUTABLE=python ${CONDA_RUN} bash backends/apple/coreml/scripts/install_requirements.sh
345+
echo "Finishing installing coreml."
346+
347+
# Build and test coreml model
348+
MODELS=(mv3 ic4 resnet50 edsr mobilebert w2l)
349+
for MODEL_NAME in "${MODELS[@]}"; do
350+
echo "::group::Exporting coreml model: $MODEL_NAME"
351+
PYTHON_EXECUTABLE=python ${CONDA_RUN} bash .ci/scripts/test_model.sh "${MODEL_NAME}" "${BUILD_TOOL}" "${BACKEND}"
352+
echo "::endgroup::"
353+
done

0 commit comments

Comments
 (0)