|
23 | 23 |
|
24 | 24 | import math |
25 | 25 | import os |
| 26 | +import platform |
26 | 27 | import sys |
27 | 28 | import tempfile |
28 | 29 | import types |
@@ -83,6 +84,23 @@ def _assert_df_quality( |
83 | 84 | ) |
84 | 85 |
|
85 | 86 |
|
| 87 | +def _macos_version() -> tuple[int, int]: |
| 88 | + """Return (major, minor) macOS version, or (0, 0) on non-macOS.""" |
| 89 | + if sys.platform != "darwin": |
| 90 | + return (0, 0) |
| 91 | + release = platform.mac_ver()[0] |
| 92 | + if not release: |
| 93 | + return (0, 0) |
| 94 | + parts = release.split(".") |
| 95 | + major = int(parts[0]) if parts and parts[0].isdigit() else 0 |
| 96 | + minor = int(parts[1]) if len(parts) > 1 and parts[1].isdigit() else 0 |
| 97 | + return (major, minor) |
| 98 | + |
| 99 | + |
| 100 | +# iOS18 CoreML models require macOS 15+ to execute at runtime. |
| 101 | +_MACOS_SUPPORTS_IOS18_RUNTIME = _macos_version() >= (15, 0) |
| 102 | + |
| 103 | + |
86 | 104 | def _print_df(df: pd.DataFrame, header: str) -> None: |
87 | 105 | with pd.option_context( |
88 | 106 | "display.max_columns", |
@@ -240,6 +258,16 @@ def test_tap_compare_static_llama_coreml(self): |
240 | 258 | with tempfile.TemporaryDirectory() as temp_dir: |
241 | 259 | pte_path = os.path.join(temp_dir, "model.pte") |
242 | 260 | et_program.save(pte_path) |
| 261 | + |
| 262 | + # iOS18-targeted CoreML models require macOS 15+ at runtime; on |
| 263 | + # older macOS we exercise AOT lowering + .pte serialization only |
| 264 | + # and skip runtime execution and the AOT-vs-runtime comparison. |
| 265 | + if not _MACOS_SUPPORTS_IOS18_RUNTIME: |
| 266 | + self.skipTest( |
| 267 | + "Skipping runtime portion: iOS18 CoreML models require " |
| 268 | + f"macOS 15+, found macOS {platform.mac_ver()[0] or 'unknown'}" |
| 269 | + ) |
| 270 | + |
243 | 271 | rt = Runtime.get() |
244 | 272 | program = rt.load_program(pte_path, verification=Verification.Minimal) |
245 | 273 | method = program.load_method("forward") |
|
0 commit comments