Skip to content
Merged
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
28 changes: 28 additions & 0 deletions devtools/intermediate_output_tap/tests/test_coreml_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import math
import os
import platform
import sys
import tempfile
import types
Expand Down Expand Up @@ -83,6 +84,23 @@ def _assert_df_quality(
)


def _macos_version() -> tuple[int, int]:
"""Return (major, minor) macOS version, or (0, 0) on non-macOS."""
if sys.platform != "darwin":
return (0, 0)
release = platform.mac_ver()[0]
if not release:
return (0, 0)
parts = release.split(".")
major = int(parts[0]) if parts and parts[0].isdigit() else 0
minor = int(parts[1]) if len(parts) > 1 and parts[1].isdigit() else 0
return (major, minor)


# iOS18 CoreML models require macOS 15+ to execute at runtime.
_MACOS_SUPPORTS_IOS18_RUNTIME = _macos_version() >= (15, 0)


def _print_df(df: pd.DataFrame, header: str) -> None:
with pd.option_context(
"display.max_columns",
Expand Down Expand Up @@ -240,6 +258,16 @@ def test_tap_compare_static_llama_coreml(self):
with tempfile.TemporaryDirectory() as temp_dir:
pte_path = os.path.join(temp_dir, "model.pte")
et_program.save(pte_path)

# iOS18-targeted CoreML models require macOS 15+ at runtime; on
# older macOS we exercise AOT lowering + .pte serialization only
# and skip runtime execution and the AOT-vs-runtime comparison.
if not _MACOS_SUPPORTS_IOS18_RUNTIME:
self.skipTest(
"Skipping runtime portion: iOS18 CoreML models require "
f"macOS 15+, found macOS {platform.mac_ver()[0] or 'unknown'}"
)

rt = Runtime.get()
program = rt.load_program(pte_path, verification=Verification.Minimal)
method = program.load_method("forward")
Expand Down
Loading