icemelon9 commented on a change in pull request #4312: [TOPI][Relay][OP] 
Dynamic NMS and strided_slice
URL: https://github.com/apache/incubator-tvm/pull/4312#discussion_r345394342
 
 

 ##########
 File path: topi/python/topi/vision/nms.py
 ##########
 @@ -366,17 +551,33 @@ def non_max_suppression(data, valid_count, 
max_output_size=-1,
     score_shape = (batch_size, num_anchors)
     score_tensor = tvm.compute(score_shape, lambda i, j: data[i, j, 
score_axis])
     sort_tensor = argsort(score_tensor, valid_count=valid_count, axis=1, 
is_ascend=False)
-    out, box_indices = hybrid_nms(data, sort_tensor, valid_count,
-                                  tvm.const(max_output_size, dtype="int32"),
-                                  tvm.const(iou_threshold, dtype=data.dtype),
-                                  tvm.const(force_suppress, dtype="bool"),
-                                  tvm.const(top_k, dtype="int32"),
-                                  tvm.const(coord_start, dtype="int32"),
-                                  tvm.const(id_index, dtype="int32"),
-                                  tvm.const(score_index, dtype="int32"),
-                                  zero=tvm.const(0, dtype=data.dtype),
-                                  one=tvm.const(1, dtype=data.dtype))
-    if not return_indices and invalid_to_bottom:
-        out = hybrid_rearrange_out(out, one=tvm.const(1, dtype=data.dtype))
-
-    return box_indices if return_indices else out
+
+    if return_indices:
+        # return a tuple with two tensor, one is the computed valid indices of 
boxes, appending -1 as invalid boxes
+        # the other one is the number of valid boxes
+        out, box_indices = hybrid_dynamic_nms(data,
+                                              sort_tensor,
+                                              tvm.const(max_output_size, 
dtype="int32"),
+                                              tvm.const(score_threshold, 
dtype=data.dtype),
+                                              tvm.const(iou_threshold, 
dtype=data.dtype),
+                                              tvm.const(score_index, 
dtype="int32"),
+                                              zero=tvm.const(0, 
dtype=data.dtype),
+                                              one=tvm.const(1, 
dtype=data.dtype))
+        box_indices, out_shape = hybrid_rearrange_idx(box_indices)
+        return [box_indices, out_shape]
 
 Review comment:
   Use tuple here

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to