-
Notifications
You must be signed in to change notification settings - Fork 128
fix (nonmaxsuppression): fix output when use_dyn_output is false (make it onnx compliant) - #4679 #4773
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix (nonmaxsuppression): fix output when use_dyn_output is false (make it onnx compliant) - #4679 #4773
Changes from 1 commit
90c6fc8
15c5a9c
dcb4136
9984033
45e5c4f
cf9b6de
6dc85ab
7189a1b
a84452f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -184,7 +184,10 @@ struct nonmaxsuppression | |
| "NonMaxSuppression: dynamic input shape with use_dyn_output set to false"); | ||
| } | ||
| fixed_shape_error_check(); | ||
| std::vector<std::size_t> out_lens = {max_num_boxes, 3}; | ||
| // actual selected boxes. Previously returned fixed max_num_boxes which caused zero padding bug. https://github.com/ROCm/AMDMIGraphX/issues/4679 | ||
| std::vector<shape::dynamic_dimension> out_lens = {}; | ||
| out_lens.push_back({0, max_num_boxes}); | ||
| out_lens.push_back({3, 3}); | ||
| return {shape::int64_type, out_lens}; | ||
|
Comment on lines
+187
to
192
|
||
| } | ||
| } | ||
|
|
@@ -321,7 +324,8 @@ struct nonmaxsuppression | |
| double iou_threshold, | ||
| double score_threshold) const | ||
| { | ||
| std::fill(output.begin(), output.end(), 0); | ||
| // We trim the output in compute() so zeros are irrelevant | ||
| // std::fill(output.begin(), output.end(), 0); | ||
|
adityas-amd marked this conversation as resolved.
|
||
| const auto& lens = scores.get_shape().lens(); | ||
| const auto num_batches = lens[0]; | ||
| const auto num_classes = lens[1]; | ||
|
|
@@ -398,14 +402,10 @@ struct nonmaxsuppression | |
| score_threshold); | ||
| }); | ||
| }); | ||
| if(use_dyn_output) | ||
| { | ||
| return result.reshape({output_shape.type(), {num_selected, 3}}); | ||
| } | ||
| else | ||
| { | ||
| return result; | ||
| } | ||
| // Previously only done when use_dyn_output==True | ||
| // Now done always - correct for both static and dynamic inputs | ||
| // This makes output ONNX spec compliant https://onnx.ai/onnx/operators/onnx__NonMaxSuppression.html | ||
| return result.reshape({output_shape.type(), {num_selected, 3}}); | ||
| } | ||
|
adityas-amd marked this conversation as resolved.
|
||
| }; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this change, compute_shape() returns the same dynamic output shape in both the use_dyn_output and !use_dyn_output branches, and compute() also reshapes unconditionally. That makes the use_dyn_output flag behavior misleading (it now mainly controls whether dynamic inputs are allowed). Consider simplifying the branching / documenting this explicitly (or deprecating the flag) so callers don’t assume it controls whether the output shape is dynamic.