Reject inverted RangeDim bounds when upper_bound is positive - #2849
Merged
TobyRoseman merged 1 commit intoSep 14, 2026
Merged
Conversation
Collaborator
|
This change looks good. CI: https://gitlab.com/coremltools1/coremltools/-/pipelines/2837972489 |
Contributor
Author
|
Thanks for the review, @TobyRoseman. I checked the two failed jobs on
The input/output shape job passed (20 passed, 22 skipped). I've left the patch unchanged. Would you recommend rerunning the TensorFlow job, or is there a particular case you'd like me to investigate further? |
TobyRoseman
approved these changes
Sep 14, 2026
Collaborator
|
Thanks @rioyu123 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Reject inverted positive finite bounds in
RangeDim.__init__with aValueErrorthat identifies both bounds, before allocating a symbol.Currently, this invalid range is accepted when
defaultis omitted:A one-op MIL-to-neural-network conversion only rejects it later, during shape processing after conversion passes have run. Checking the bounds at construction reports the configuration error at its source. An inverted range is already rejected during neural-network conversion; this reports it at construction instead. ML Program emission was not exercised (see Testing).
The guard applies only when
upper_bound > 0. Equal bounds, lower bound zero, valid finite ranges, andupper_bound=-1remain supported. Existing non-positive-upper-bound policy and__ior__are untouched. Tests cover omitted and explicit defaults for inverted ranges, plus the valid cases.Testing
On Linux / Python 3.12.3, using the source checkout:
main(c59d1a2fe535367db7b9b95a8cc2cffaa82dac4d): 3 failed, 11 passed. Omitted default does not raise; explicit defaults raise the older default-validation messages instead of identifying the inverted bounds.ct.RangeDim(lower_bound=5, upper_bound=3)call now raises immediately.git diff --checkand compilation of the modified Python files passed.These are source-only Python checks, not the full native build/CI suite. macOS inference was not tested. The separate ML Program reproduction could not complete because
BlobWriterwas unavailable; the late-rejection reproduction above uses the neural-network backend.