Conversation
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.
Summary
This PR improves robustness in quantized conversion paths and adds a new NonMaxSuppression option for class-score shrinking.
It addresses three concrete conversion failures seen during real model conversion, and adds a user-facing CLI/API switch for NMS behavior.
Background / Motivation
While converting quantized and post-process-heavy models, the following failure patterns were observed:
QLinearConvaborted when output shape metadata wasNonein theauto_pad == 'NOTSET'path.QLinearConvdepthwise weight reshape failed with mismatched element counts (invalid reshape target).PRelufailed broadcasting when slope was channel-first style (e.g.[C,1,1]) but runtime tensor layout was channel-last.In addition, for some NMS post-processing models (e.g. DAMO-YOLO style layouts), users requested a mode to shrink
scoresclass dimension by argmax before NMS.Changes
1) QLinearConv robustness fixes
File:
onnx2tf/ops/QLinearConv.pyoutput_tensor_shape[2:]directlyNonebefore comparison[..., input_weights_shape[2], input_weights_shape[3] // group][..., -1, input_weights_shape[3] // group]Conv.pyand avoids invalid reshape size errors.2) PRelu slope layout alignment
File:
onnx2tf/ops/PRelu.py[N,H,W,C][C,1,1][1,1,C]3) New NMS option:
--output_nms_with_argmax(-onwa)Files:
onnx2tf/onnx2tf.pyonnx2tf/ops/NonMaxSuppression.pyREADME.mdAdded new CLI/API option to shrink class dimension of NMS
scores:[B, C, N][B, 1, N]Implementation details in
NonMaxSuppression.py:argmax(scores, axis=1)reduce_max(..., keepdims=True))[batch_index, class_index, box_index]by gathering class ids for selected boxes4) Documentation and version update
Files:
README.mdonnx2tf/__init__.pypyproject.tomlDocumented the new NMS argmax option in README (CLI and Python API sections).
Updated version from
2.0.8to2.0.9.Validation
python -m py_compile onnx2tf/onnx2tf.py onnx2tf/ops/QLinearConv.py onnx2tf/ops/PRelu.py onnx2tf/ops/NonMaxSuppression.py onnx2tf/__init__.py[batch, class, box].Compatibility / Risk
--output_nms_with_argmaxis explicitly enabled.QLinearConvandPReluchanges are defensive and targeted at previously failing shape/layout edge cases.Issue
ArgMaxforce-replacement option forNMSwith associated class score refinement. #420