You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by zh...@apache.org on 2018/05/04 19:47:47 UTC

[incubator-mxnet] branch master updated: fix topk nms in multibox_detection operator (#10794)

This is an automated email from the ASF dual-hosted git repository.

zhreshold pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/master by this push:
     new 38ec93c  fix topk nms in multibox_detection operator (#10794)
38ec93c is described below

commit 38ec93cbf32ddea921319cf0fd8e446b7e3e9b6b
Author: Wang Jiajun <wa...@gmail.com>
AuthorDate: Sat May 5 03:47:40 2018 +0800

    fix topk nms in multibox_detection operator (#10794)
---
 src/operator/contrib/multibox_detection.cc | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/operator/contrib/multibox_detection.cc b/src/operator/contrib/multibox_detection.cc
index a2e681a..112c033 100644
--- a/src/operator/contrib/multibox_detection.cc
+++ b/src/operator/contrib/multibox_detection.cc
@@ -142,7 +142,11 @@ 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) {
@@ -150,10 +154,10 @@ inline void MultiBoxDetectionForward(const Tensor<cpu, 3, DType> &out,
       }
     }
     // 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])) {

-- 
To stop receiving notification emails like this one, please contact
zhreshold@apache.org.