File tree Expand file tree Collapse file tree 5 files changed +26
-5
lines changed Expand file tree Collapse file tree 5 files changed +26
-5
lines changed Original file line number Diff line number Diff line change @@ -244,8 +244,17 @@ test_model_with_coreml() {
244244}
245245
246246test_model_with_mps () {
247- " ${PYTHON_EXECUTABLE} " -m examples.apple.mps.scripts.mps_example --model_name=" ${MODEL_NAME} " --use_fp16
247+ " ${PYTHON_EXECUTABLE} " -m examples.apple.mps.scripts.mps_example --model_name=" ${MODEL_NAME} " --use_fp16 --bundled
248248 EXPORTED_MODEL=$( find " ." -type f -name " ${MODEL_NAME} *.pte" -print -quit)
249+
250+ if [ -z " ${EXPORTED_MODEL} " ]; then
251+ echo " [error] failed to export model: no .pte file found"
252+ exit 1
253+ fi
254+
255+ echo " Testing exported model with mps_executor_runner..."
256+ ./examples/apple/mps/scripts/build_mps_executor_runner.sh
257+ ./cmake-out/examples/apple/mps/mps_executor_runner -bundled_program=True -model_path=" ${EXPORTED_MODEL} "
249258}
250259
251260if [[ " ${BACKEND} " == " portable" ]]; then
Original file line number Diff line number Diff line change 1919 model = Model .Mv3 ,
2020 backend = Backend .CoreMlExportAndTest ,
2121 ),
22+ test_base .ModelTest (
23+ model = Model .Mv3 ,
24+ backend = Backend .AppleMPS ,
25+ ),
2226 ]
2327 )
Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22# Copyright (c) 2024 Apple Inc. All rights reserved.
33# Provided subject to the LICENSE file in the top level directory.
4+ #
5+ # Copyright (c) Meta Platforms, Inc. and affiliates.
6+ # All rights reserved.
7+ #
8+ # This source code is licensed under the BSD-style license found in the
9+ # LICENSE file in the root directory of this source tree.
10+
411
512set -e
613
@@ -44,19 +51,18 @@ cmake -DBUCK2="$BUCK" \
4451 -DEXECUTORCH_BUILD_DEVTOOLS=ON \
4552 -DEXECUTORCH_ENABLE_EVENT_TRACER=ON \
4653 -DEXECUTORCH_BUILD_MPS=ON \
47- -DPYTHON_EXECUTABLE= " $PYTHON_EXECUTABLE " \
54+ -DEXECUTORCH_ENABLE_LOGGING=ON \
4855 -Bcmake-out .
49- cmake --build cmake-out -j9 --target install --config " $MODE "
56+ cmake --build cmake-out -j $( sysctl -n hw.ncpu ) --target install --config " $MODE "
5057CMAKE_PREFIX_PATH=" ${PWD} /cmake-out/lib/cmake/ExecuTorch;${PWD} /cmake-out/third-party/gflags"
5158# build mps_executor_runner
5259rm -rf cmake-out/examples/apple/mps
5360cmake \
5461 -DCMAKE_PREFIX_PATH=" $CMAKE_PREFIX_PATH " \
5562 -DCMAKE_BUILD_TYPE=" $MODE " \
56- -DPYTHON_EXECUTABLE=" $PYTHON_EXECUTABLE " \
5763 -Bcmake-out/examples/apple/mps \
5864 examples/apple/mps
5965
60- cmake --build cmake-out/examples/apple/mps -j9 --config " $MODE "
66+ cmake --build cmake-out/examples/apple/mps -j $( sysctl -n hw.ncpu ) --config " $MODE "
6167
6268echo " Build succeeded!"
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ class Backend(str, Enum):
4646 XnnpackQuantizationDelegation = "xnnpack-quantization-delegation"
4747 CoreMlExportOnly = "coreml"
4848 CoreMlExportAndTest = "coreml-test" # AOT export + test with runner
49+ AppleMPS = "mps"
4950
5051 def __str__ (self ) -> str :
5152 return self .value
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ set_overridable_option(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)
2222
2323if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" )
2424 set_overridable_option(EXECUTORCH_BUILD_COREML ON )
25+ set_overridable_option(EXECUTORCH_BUILD_MPS ON )
2526elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux" )
2627 set_overridable_option(EXECUTORCH_BUILD_COREML ON )
2728elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows" OR CMAKE_SYSTEM_NAME STREQUAL "WIN32" )
You can’t perform that action at this time.
0 commit comments