yongwww commented on a change in pull request #7137:
URL: https://github.com/apache/tvm/pull/7137#discussion_r548404381



##########
File path: tests/python/frontend/pytorch/test_object_detection.py
##########
@@ -70,7 +71,7 @@ def generate_jit_model(index):
     ]
 
     model_func = model_funcs[index]
-    model = TraceWrapper(model_func(pretrained=True))
+    model = TraceWrapper(model_func(pretrained=True, 
rpn_pre_nms_top_n_test=200))

Review comment:
       Glad to see `rpn_pre_nms_top_n_test ` is able to limit the proposals 
before nms. I am not sure if the parameter is specified for real use cases, 
seems using default of the parameter to do benchamarking makes more sense to me

##########
File path: python/tvm/relay/frontend/pytorch.py
##########
@@ -1857,16 +1857,18 @@ def nms(self, inputs, input_types):
         scores = inputs[1]
         iou_threshold = inputs[2]
 
+        num_boxes = _op.shape_of(scores)
+
+        # TVM NMS assumes score > 0
+        scores = scores - _op.min(scores) + _op.const(1.0)
         # Generate data with shape (1, num_anchors, 5)
         scores = AttrCvt(op_name="expand_dims", extras={"axis": -1, 
"num_newaxis": 1})([scores], {})
-
-        # Prepare input data for get_valid_counts
         data = _op.concatenate([scores, boxes], -1)
         data = _op.expand_dims(data, 0, 1)
-        # Leverage get_valid_counts to sort the data and clear invalid boxes
-        ct, data, indices = get_relay_op("get_valid_counts")(
-            data, score_threshold=-1.0, id_index=-1, score_index=0
-        )
+        # PyTorch NMS doesn't have score_threshold, so no need to run 
get_valid_count

Review comment:
       then in this case, the nms will compute for all boxes, the perf should 
be bad. Not sure how PyTorch speeds up the computation for boxes with negative 
score.




----------------------------------------------------------------
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]


Reply via email to