fix qlinear nan bug#4914
Open
aarushjain29 wants to merge 9 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts MIGraphX’s quantizelinear operator to handle NaN inputs deterministically during quantization, aligning behavior with common ONNX runtime expectations (notably ONNX Runtime CPU EP).
Changes:
- Add explicit NaN handling for integral quantization outputs: NaN inputs now saturate to the quantized type’s minimum value.
- Prevent NaN from flowing through the clamp logic (
std::min/std::max) where it would otherwise silently select the max bound.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #4914 +/- ##
===========================================
- Coverage 92.66% 92.62% -0.04%
===========================================
Files 588 587 -1
Lines 30412 30416 +4
===========================================
- Hits 28180 28171 -9
- Misses 2232 2245 +13
🚀 New features to boost your workflow:
|
Regressions detected 🔴 |
|
TedThemistokleous
requested changes
May 28, 2026
TedThemistokleous
approved these changes
Jun 3, 2026
Collaborator
TedThemistokleous
left a comment
There was a problem hiding this comment.
Fix tidy but otherwise lgtm
Collaborator
|
TODO: when testing is updated to check actual values on ref+gpu, add a test for this case |
CharlieL7
approved these changes
Jun 4, 2026
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.
Motivation
ONNX Runtime's CPUExecutionProvider and MIGraphX disagreed on QuantizeLinear output when the input is NaN:
input: [nan]
scale: 0.5
onnxruntime out: [-128]
migraphx out: [ 127] ← MIGraphX
Technical Details
Changelog Category
Add a
CHANGELOG.mdentry for any option other thanNot Applicable