Commit 012f399
authored
fix: raise CoreMLExportError on incompatible palettization configs (#44)
* refactor: add validate_coreml_palettization_compatibility for combo checks
Vector palettization, LUT quantization, and per-channel scale are each
independently CoreML-exportable, but combining any two breaks CoreML/MIL's
constexpr_lut_to_dense op with a rank mismatch, a missing vector_axis, or an
indices/LUT divisibility error depending on the pair. Add a dedicated
validator (composing the existing LUT dtype check) so the kmeans export path
has one entry point to reject these combinations with a clear
CoreMLExportError, instead of relying on a test-side skip to hide them.
* refactor: reject unsupported palettization combos in kmeans CoreML export
Wire validate_coreml_palettization_compatibility into prepare_for_mil_export
so finalize(backend=CoreML) raises immediately for a combo it can't fuse
into a single compatible op chain, rather than emitting an invalid model or
crashing deep inside ct.convert.
* test: reject unsupported kmeans palettization combos on CoreML export
Replace the pytest.skip-based _skip_unsupported_mil_configs with a predicate
(_has_unsupported_mil_combo) and assert finalize() raises CoreMLExportError,
mirroring the existing float-LUT-dtype rejection path. Rename
_assert_coreml_rejects_unsupported_lut to _assert_coreml_rejects since it's
now shared by both rejection cases.1 parent 3f5b05d commit 012f399
3 files changed
Lines changed: 82 additions & 43 deletions
File tree
- src/coreai_opt
- _utils
- palettization/kmeans
- tests/export
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
81 | 128 | | |
82 | 129 | | |
83 | 130 | | |
| |||
Lines changed: 11 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | 25 | | |
27 | 26 | | |
28 | 27 | | |
| |||
430 | 429 | | |
431 | 430 | | |
432 | 431 | | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | | - | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
439 | 442 | | |
440 | 443 | | |
441 | 444 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
72 | 72 | | |
73 | | - | |
74 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
75 | 77 | | |
76 | 78 | | |
77 | 79 | | |
| |||
95 | 97 | | |
96 | 98 | | |
97 | 99 | | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
106 | 107 | | |
107 | 108 | | |
108 | 109 | | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
| 110 | + | |
124 | 111 | | |
125 | 112 | | |
126 | 113 | | |
| |||
134 | 121 | | |
135 | 122 | | |
136 | 123 | | |
137 | | - | |
138 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
139 | 129 | | |
140 | 130 | | |
141 | | - | |
142 | | - | |
143 | 131 | | |
144 | 132 | | |
145 | 133 | | |
| |||
175 | 163 | | |
176 | 164 | | |
177 | 165 | | |
178 | | - | |
179 | | - | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
180 | 171 | | |
181 | 172 | | |
182 | | - | |
183 | | - | |
184 | 173 | | |
185 | 174 | | |
186 | 175 | | |
| |||
0 commit comments