Skip to content

Commit 1663dde

Browse files
committed
test: rename CoreML rejection assertion helper for dtype+granularity clarity
assert_coreml_finalize_rejects_unsupported_dtype and COREML_DTYPE_REJECTION_MATCH are now used for granularity rejections too, not just dtype ones, so their names no longer matched what they check.
1 parent 94e0245 commit 1663dde

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

tests/export/export_utils.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@
2929
if platform.system() == "Darwin":
3030
from coreai.runtime import ComputeUnitKind, SpecializationOptions
3131

32-
# Substring of the dtype guard message raised by the CoreML export validation. Shared so
33-
# test files asserting the rejection don't drift from one another.
34-
COREML_DTYPE_REJECTION_MATCH = "CoreML export does not support"
32+
# Substring of the guard message raised by CoreML export validation (dtype or
33+
# granularity/config rejection). Shared so test files asserting the rejection
34+
# don't drift from one another.
35+
COREML_REJECTION_MATCH = "CoreML export does not support"
3536

3637
# Compute unit selection driven by the --compute-unit-kind pytest option (see
3738
# tests/conftest.py). Default is "interpreter" so a plain `pytest` run uses the
@@ -87,17 +88,18 @@ def _get_test_specialization_options() -> "SpecializationOptions | None":
8788
raise ValueError(msg)
8889

8990

90-
def assert_coreml_finalize_rejects_unsupported_dtype(finalizer: Any) -> None:
91-
"""Assert ``finalizer.finalize(backend=CoreML)`` rejects an unsupported dtype.
91+
def assert_coreml_finalize_rejects(finalizer: Any) -> None:
92+
"""Assert ``finalizer.finalize(backend=CoreML)`` rejects an unsupported config.
9293
9394
CoreML does not support FP4, FP8, INT2, or UINT2 quantization or
94-
palettization dtypes, so finalize must raise a ``CoreMLExportError`` rather
95-
than emit an invalid model.
95+
palettization dtypes, nor per-channel/per-block activation quantization
96+
granularity, so finalize must raise a ``CoreMLExportError`` rather than
97+
emit an invalid model.
9698
9799
Args:
98100
finalizer (Any): A prepared ``Quantizer`` or ``KMeansPalettizer``.
99101
"""
100-
with pytest.raises(CoreMLExportError, match=COREML_DTYPE_REJECTION_MATCH):
102+
with pytest.raises(CoreMLExportError, match=COREML_REJECTION_MATCH):
101103
finalizer.finalize(backend=ExportBackend.CoreML)
102104

103105

tests/export/test_kmeans_export.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def _assert_coreml_rejects_unsupported_lut(
7676
model.eval()
7777
palettizer = KMeansPalettizer(model, config)
7878
palettizer.prepare((input_data,))
79-
export_utils.assert_coreml_finalize_rejects_unsupported_dtype(palettizer)
79+
export_utils.assert_coreml_finalize_rejects(palettizer)
8080

8181

8282
def _skip_heavy_mnist_configs(config: ParametrizedPalettConfigs) -> None:

0 commit comments

Comments
 (0)