Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
fix topk nms in multibox_detection operator (#10794)
Browse files Browse the repository at this point in the history
  • Loading branch information
arcadiaphy authored and zhreshold committed May 4, 2018
1 parent 66365ef commit 38ec93c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/operator/contrib/multibox_detection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,22 @@ inline void MultiBoxDetectionForward(const Tensor<cpu, 3, DType> &out,
DType *ptemp = temp_space.dptr_ + nbatch * num_anchors * 6;
int nkeep = static_cast<int>(sorter.size());
if (nms_topk > 0 && nms_topk < nkeep) {
// keep topk detections
nkeep = nms_topk;
for (int i = nkeep; i < valid_count; ++i) {
p_out[i * 6] = -1;
}
}
for (int i = 0; i < nkeep; ++i) {
for (int j = 0; j < 6; ++j) {
p_out[i * 6 + j] = ptemp[sorter[i].index * 6 + j];
}
}
// apply nms
for (int i = 0; i < valid_count; ++i) {
for (int i = 0; i < nkeep; ++i) {
int offset_i = i * 6;
if (p_out[offset_i] < 0) continue; // skip eliminated
for (int j = i + 1; j < valid_count; ++j) {
for (int j = i + 1; j < nkeep; ++j) {
int offset_j = j * 6;
if (p_out[offset_j] < 0) continue; // skip eliminated
if (force_suppress || (p_out[offset_i] == p_out[offset_j])) {
Expand Down

0 comments on commit 38ec93c

Please sign in to comment.