onnxruntime
7abc315f - fix: preserve Q/DQ around Resize when mode is linear or cubic (#28414)

Commit
1 day ago
fix: preserve Q/DQ around Resize when mode is linear or cubic (#28414) ### Description `DropQDQNodeGroupSelector::Check` unconditionally removes the surrounding Q/DQ pair from a `Resize` node. This is only safe when `mode="nearest"`. For `mode="linear"` and `mode="cubic"`, interpolation is not order-preserving on integer scales, so folding Q/DQ into the integer Resize produces numerically incorrect results. This change adds a Resize-specific guard inside `DropQDQNodeGroupSelector::Check` that reads the `mode` attribute (defaulting to `"nearest"` per the ONNX spec when absent) and refuses the drop when the mode is anything other than `"nearest"`. `DepthToSpace`, which shares the same selector registration, is unaffected. A regression test in `qdq_transformer_test.cc` exercises `mode="linear"` and `mode="cubic"`, with and without contrib QDQ ops, and asserts that the Q/DQ pair is preserved (Q and DQ counts remain at 1). ### Motivation and Context Fixes #21319. The reproducer in the issue runs a uint8-quantized model with a `mode="linear"` Resize and expects `[[[[0, 0, 1, 1]]]]` but gets `[[[[0, 0, 0, 1]]]]` because the optimizer folded the Q/DQ pair away and ran linear interpolation in int8. After this change, the Q/DQ pair stays in place and the resulting graph matches the `onnx.reference` output.
Author
Parents
Loading