[AIRADSW-567] Fix int8 models qlinearconv#4969
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #4969 +/- ##
========================================
Coverage 92.73% 92.73%
========================================
Files 592 592
Lines 31289 31289
========================================
Hits 29015 29015
Misses 2274 2274
🚀 New features to boost your workflow:
|
TedThemistokleous
approved these changes
Jun 16, 2026
CharlieL7
requested changes
Jun 16, 2026
CharlieL7
left a comment
Collaborator
There was a problem hiding this comment.
The fix looks correct. Please add an ONNX parse test for the per tensor parsing case in test/onnx/parse/qlinearconv_test.cpp
Regressions detected 🔴 |
|
Co-authored-by: Charlie Lin <charlie.lin@amd.com>
Collaborator
Author
|
I've added it. Thanks. |
CharlieL7
approved these changes
Jun 17, 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
QLinearConvmodels that have a bias and use per-tensor (scalar) weight quantization fail to parse. The parser throws while building the biasdequantizelinear:This blocks loading common quantized models such as
resnet50_int8. The goal of this PR is to makeQLinearConvwith bias parse correctly for both per-tensor and per-axis (per-channel) weight scales, and to add a regression test for the previously-uncovered per-tensor case.This is a regression introduced by #4521. Before that change, the int32 bias was added to the convolution result without being dequantized (numerically incorrect, but it parsed). #4521 added the correct bias dequantization (
bias_scale = x_scale * w_scale), but only handled the per-axis weight-scale shape, so per-tensor models began throwing at parse time.Technical Details
When
QLinearConvhas a bias, the parser dequantizes the int32 bias using a scale computed asx_scale * w_scale:bias_scaleinherits the shape of the weight scale (in_scale_w):in_scale_wis{out_channels}, sobias_scaleis{out_channels}and matches the bias{out_channels}. Works.in_scale_wis a scalar{1}, sobias_scaleis{1}while the bias is{out_channels}.Fix
Broadcast
bias_scaleto the bias shape before the biasdequantizelinear:This is a minimal, single-instruction change confined to the
if(args.size() > 8)(bias-present) branch ofparse_qlinearconv:{1}→{out_channels}— fixes the crash.{out_channels}→{out_channels}— an identity broadcast, so numerics are unchanged and the existingqlinearconv_perchannel_weightbias_teststill passes.Related
cf56c399b).Changelog Category
Add a
CHANGELOG.mdentry for any option other thanNot Applicable