Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions .ci/scripts/test_model.sh
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,14 @@ test_model_with_qnn() {
EXPORTED_MODEL=$(find "./${EXPORT_SCRIPT}" -type f -name "${MODEL_NAME}*.pte" -print -quit)
}

# Run CoreML tests.
#
# @param should_test If true, build and test the model using the coreml_executor_runner.
test_model_with_coreml() {
if [[ "${BUILD_TOOL}" == "buck2" ]]; then
echo "coreml doesn't support buck2."
local should_test="$1"

if [[ "${BUILD_TOOL}" != "cmake" ]]; then
echo "coreml only supports cmake."
exit 1
fi

Expand All @@ -229,6 +234,14 @@ test_model_with_coreml() {
echo "No .pte file found"
exit 1
fi

# Run the model
if [ "${should_test}" = true ]; then
echo "Testing exported model with coreml_executor_runner..."
local out_dir=$(mktemp -d)
COREML_EXECUTOR_RUNNER_OUT_DIR="${out_dir}" examples/apple/coreml/scripts/build_executor_runner.sh
"${out_dir}/coreml_executor_runner" --model_path "${EXPORTED_MODEL}"
fi
}

test_model_with_mps() {
Expand All @@ -247,7 +260,11 @@ elif [[ "${BACKEND}" == *"qnn"* ]]; then
fi
elif [[ "${BACKEND}" == *"coreml"* ]]; then
echo "Testing ${MODEL_NAME} with coreml..."
test_model_with_coreml
should_test_coreml=false
if [[ "${BACKEND}" == *"test"* ]]; then
should_test_coreml=true
fi
test_model_with_coreml "${should_test_coreml}"
if [[ $? -eq 0 ]]; then
prepare_artifacts_upload
fi
Expand Down
8 changes: 7 additions & 1 deletion .ci/scripts/wheel/test_macos.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
test_base.ModelTest(
model=Model.Mv3,
backend=Backend.XnnpackQuantizationDelegation,
)
),
# Enable this once CoreML is suppported out-of-the-box
# https://github.com/pytorch/executorch/issues/9019
# test_base.ModelTest(
# model=Model.Mv3,
# backend=Backend.CoreMlTest,
# )
]
)
9 changes: 8 additions & 1 deletion examples/apple/coreml/scripts/build_executor_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,11 @@ XCODE_WORKSPACE_DIR_PATH="$EXAMPLES_COREML_DIR_PATH/executor_runner"
XCODE_BUILD_DIR_PATH="$EXAMPLES_COREML_DIR_PATH/xcode-build"

xcodebuild build -workspace "$XCODE_WORKSPACE_DIR_PATH/coreml_executor_runner.xcworkspace" -scheme coreml_executor_runner BUILD_DIR="$XCODE_BUILD_DIR_PATH"
cp -f "$XCODE_BUILD_DIR_PATH/DEBUG/coreml_executor_runner" "$PWD"

if [[ -z "${COREML_EXECUTOR_RUNNER_OUT_DIR:-}" ]]; then
COREML_EXECUTOR_RUNNER_OUT_DIR=$(pwd)
elif [[ ! -d "${COREML_EXECUTOR_RUNNER_OUT_DIR}" ]]; then
mkdir -p "${COREML_EXECUTOR_RUNNER_OUT_DIR}"
fi
cp -f "$XCODE_BUILD_DIR_PATH/DEBUG/coreml_executor_runner" "${COREML_EXECUTOR_RUNNER_OUT_DIR}"
echo "created ${COREML_EXECUTOR_RUNNER_OUT_DIR}/coreml_executor_runner"
1 change: 1 addition & 0 deletions examples/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def __str__(self) -> str:

class Backend(str, Enum):
XnnpackQuantizationDelegation = "xnnpack-quantization-delegation"
CoreMlTest = "coreml-test"

def __str__(self) -> str:
return self.value
Expand Down
Loading