Repository navigation
Conversation
173787247
force-pushed
the
fix/onnx-clip-default-bounds
branch
2 times, most recently
from
October 29, 2026 01:10
10f560d to
21bebe0
Compare
ONNX Clip-13 defines omitted min/max inputs as the finite limits of the input dtype. The frontend skipped the clamp entirely in that case, so an input containing infinities came out unchanged instead of clamped to the dtype limits. Emit the maximum/minimum with dtype limits when the corresponding input is absent, keeping the NaN-bound handling for provided bounds. Use a constant of the input dtype so the result dtype is preserved, and skip the clamp for integer inputs where the limit is identity. Update the Clip expectations for the min-only, max-only and no-bound cases, and add an ONNX Runtime checked regression test for the omitted bounds.
173787247
force-pushed
the
fix/onnx-clip-default-bounds
branch
from
October 29, 2026 01:10
21bebe0 to
6113bb3
Compare
This branch has not been deployed
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.
Fixes #20841
Problem
For Clip-13, when the optional
min/maxinputs are omitted, ONNX defines the bounds as the finite limits of the input dtype. The frontend returned the input unchanged in that case, so infinities survived instead of being clamped to the dtype limits.Example: float32 input
[+inf, -inf, 0]throughClipwith nomin/max:[FLT_MAX, -FLT_MAX, 0][+inf, -inf, 0]Change
Clip._impl_v13now emits the clamp with the dtype limits whenmin/maxis absent (numpy.finfo/iinfofor float and integer dtypes; dtypes unknown to numpy keep the previous unbounded default).test_clip_v13_omitted_bounds, checked against ONNX Runtime.Validation
pytest tests/python/relax/test_frontend_onnx.py -k clippasses (8 tests), and the reported input now produces[FLT_MAX, -FLT_MAX, 0].