File tree Expand file tree Collapse file tree 4 files changed +25
-10
lines changed
examples/apple/mps/scripts Expand file tree Collapse file tree 4 files changed +25
-10
lines changed Original file line number Diff line number Diff line change @@ -197,6 +197,11 @@ test_model_with_coreml() {
197197 fi
198198}
199199
200+ test_model_with_mps () {
201+ " ${PYTHON_EXECUTABLE} " -m examples.apple.mps.scripts.mps_example --model_name=" ${MODEL_NAME} " --use_fp16
202+ EXPORTED_MODEL=$( find " ." -type f -name " ${MODEL_NAME} *.pte" -print -quit)
203+ }
204+
200205if [[ " ${BACKEND} " == " portable" ]]; then
201206 echo " Testing ${MODEL_NAME} with portable kernels..."
202207 test_model
@@ -212,6 +217,12 @@ elif [[ "${BACKEND}" == "coreml" ]]; then
212217 if [[ $? -eq 0 ]]; then
213218 prepare_artifacts_upload
214219 fi
220+ elif [[ " ${BACKEND} " == " mps" ]]; then
221+ echo " Testing ${MODEL_NAME} with mps..."
222+ test_model_with_mps
223+ if [[ $? -eq 0 ]]; then
224+ prepare_artifacts_upload
225+ fi
215226elif [[ " ${BACKEND} " == " xnnpack" ]]; then
216227 echo " Testing ${MODEL_NAME} with xnnpack..."
217228 WITH_QUANTIZATION=true
Original file line number Diff line number Diff line change @@ -169,6 +169,8 @@ jobs:
169169 DELEGATE_CONFIG="xnnpack+custom+qe"
170170 elif [[ ${{ matrix.delegate }} == "coreml" ]]; then
171171 DELEGATE_CONFIG="coreml"
172+ elif [[ ${{ matrix.delegate }} == "mps" ]]; then
173+ DELEGATE_CONFIG="mps"
172174 fi
173175 PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
174176 bash .ci/scripts/test_llama.sh "${{ matrix.model }}" "${BUILD_MODE}" "${DTYPE}" "${DELEGATE_CONFIG}" "${ARTIFACTS_DIR_NAME}"
Original file line number Diff line number Diff line change @@ -311,8 +311,8 @@ jobs:
311311 PYTHON_EXECUTABLE=python bash .ci/scripts/build-qnn-sdk.sh
312312 PYTHON_EXECUTABLE=python bash .ci/scripts/test_model.sh ${{ matrix.model }} "cmake" "qnn"
313313
314- test-coreml -model :
315- name : test-coreml -model
314+ test-apple -model :
315+ name : test-apple -model
316316 uses : pytorch/test-infra/.github/workflows/macos_job.yml@main
317317 strategy :
318318 fail-fast : false
@@ -324,20 +324,25 @@ jobs:
324324 timeout : 90
325325 script : |
326326 BUILD_TOOL=cmake
327- BACKEND=coreml
328327
329328 bash .ci/scripts/setup-conda.sh
330329
331330 # Setup MacOS dependencies as there is no Docker support on MacOS atm
332331 PYTHON_EXECUTABLE=python ${CONDA_RUN} bash .ci/scripts/setup-macos.sh "${BUILD_TOOL}"
333332 PYTHON_EXECUTABLE=python ${CONDA_RUN} bash backends/apple/coreml/scripts/install_requirements.sh
334333 echo "Finishing installing coreml."
334+ PYTHON_EXECUTABLE=python ${CONDA_RUN} bash backends/apple/mps/install_requirements.sh
335+ echo "Finishing installing mps."
335336
336337 # Build and test coreml model
337338 MODELS=(mv3 ic4 resnet50 edsr mobilebert w2l)
338339 for MODEL_NAME in "${MODELS[@]}"; do
339340 echo "::group::Exporting coreml model: $MODEL_NAME"
340- PYTHON_EXECUTABLE=python ${CONDA_RUN} bash .ci/scripts/test_model.sh "${MODEL_NAME}" "${BUILD_TOOL}" "${BACKEND}"
341+ PYTHON_EXECUTABLE=python ${CONDA_RUN} bash .ci/scripts/test_model.sh "${MODEL_NAME}" "${BUILD_TOOL}" "coreml"
342+ echo "::endgroup::"
343+
344+ echo "::group::Exporting mps model: $MODEL_NAME"
345+ PYTHON_EXECUTABLE=python ${CONDA_RUN} bash .ci/scripts/test_model.sh "${MODEL_NAME}" "${BUILD_TOOL}" "mps"
341346 echo "::endgroup::"
342347 done
343348
Original file line number Diff line number Diff line change @@ -195,18 +195,15 @@ def get_model_config(args):
195195 edge_compile_config = exir .EdgeCompileConfig (_check_ir_validity = False ),
196196 ).to_executorch (config = ExecutorchBackendConfig (extract_delegate_segments = False ))
197197
198- model_name = f"{ args .model_name } _mps"
198+ dtype = "float16" if args .use_fp16 else "float32"
199+ model_name = f"{ args .model_name } _mps_{ dtype } "
199200
200201 if args .bundled :
201202 expected_output = model (* example_inputs )
202203 bundled_program_buffer = get_bundled_program (
203204 executorch_program , example_inputs , expected_output
204205 )
205- model_name = f"{ model_name } _bundled"
206- extension = "fp16"
207- if not args .use_fp16 :
208- extension = "fp32"
209- model_name = f"{ model_name } _{ extension } .pte"
206+ model_name = f"{ model_name } _bundled.pte"
210207
211208 if args .generate_etrecord :
212209 etrecord_path = "etrecord.bin"
You can’t perform that action at this time.
0 commit comments