Fix incorrect output for QDQ Resize with non-nearest interpolation modes under ORT_ENABLE_ALL - #28454
Conversation
…odes Agent-Logs-Url: https://github.com/microsoft/onnxruntime/sessions/2430b485-5b63-49fe-8aa7-d20ad2763177 Co-authored-by: tianleiwu <30328909+tianleiwu@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/onnxruntime/sessions/2430b485-5b63-49fe-8aa7-d20ad2763177 Co-authored-by: tianleiwu <30328909+tianleiwu@users.noreply.github.com>
Review — QDQ drop guard for non-nearest ResizeVerdict: Fix is correct and well-tested. One substantive caveat worth confirming; the rest are polish. The change correctly prevents 🟠 Major (worth addressing / confirming scope)Nearest is not a pure value copy under
🟡 Minor
🔵 Nits
✅ Praise
Reviewed with a multi-model agent team (readability, code, adversarial, and deep spec reviewers). |
titaiwangms
left a comment
There was a problem hiding this comment.
Non-blocking:
The new tf_crop_and_resize guard branch is untested (code + critical reviewers). The shared helper BuildQDQResizeTestCase always builds an empty {0} roi (qdq_test_utils.h:303), and a valid tf_crop_and_resize requires a 2*rank roi (upsample.cc:1091), so the new branch can't be reached through it. A regression deleting/misspelling that condition wouldn't be caught. Fix: a dedicated test builder supplying a valid roi + mode="nearest" + tf_crop_and_resize, asserting Q/DQ preserved. (The author honestly documented this gap in a test comment.)
Description
qdq_selectors.cc: InDropQDQNodeGroupSelector::Check, add a guard that skips the QDQ-drop optimization when the target node isResizewith a non-nearestmodeattribute ("linear","cubic", etc.). Whenmodeis absent the ONNX default is"nearest", so the optimization remains allowed in that case.qdq_transformer_test.cc: AddResize_Linear_No_QDQ_Droptest asserting that DQ/Q nodes are preserved aroundResizeforlinearandcubicmodes after Level2 optimization.Motivation and Context
The
DropQDQoptimizer incorrectly dropped the surrounding DQ/Q nodes for allResizemodes. Dropping these nodes bypasses float-space interpolation —Resizeends up operating directly on raw quantized integers, producing wrong results.The optimization is only semantically valid for
mode="nearest", which copies existing quantized values without arithmetic. For interpolating modes, the fullDQ → Resize → Qchain must execute in float space:Input
[2.0, 7.0, 4.0]upsampled 1×1×1×3 → 1×1×1×6 withhalf_pixel:[2.0, 3.0, 6.0, 6.0, 5.0, 4.0][2.0, 3.0, 5.0, 6.0, 4.0, 4.0]