kevinthesun commented on a change in pull request #5844: URL: https://github.com/apache/incubator-tvm/pull/5844#discussion_r442390568
########## File path: topi/python/topi/vision/nms.py ########## @@ -326,30 +329,40 @@ def hybrid_nms(data, sorted_index, valid_count, indices, batch_size, num_anchors # Apply nms box_start_idx = coord_start batch_idx = i + num_valid_boxes = 0 for j in range(valid_count[i]): - if output[i, j, score_index] > 0 and (id_index < 0 or output[i, j, id_index] >= 0): + if num_valid_boxes == max_output_size: + for k in range(box_data_length): + output[i, j, k] = -one + box_indices[i, j] = -1 + + elif output[i, j, score_index] > 0: box_a_idx = j - for k in parallel(valid_count[i]): + is_valid_box = 1 + + # a_l: left, a_t: top, a_r: right, a_b: bottom + a_l = min(output[batch_idx, box_a_idx, box_start_idx], + output[batch_idx, box_a_idx, box_start_idx + 2]) + a_t = min(output[batch_idx, box_a_idx, box_start_idx + 1], + output[batch_idx, box_a_idx, box_start_idx + 3]) + a_r = max(output[batch_idx, box_a_idx, box_start_idx], + output[batch_idx, box_a_idx, box_start_idx + 2]) + a_b = max(output[batch_idx, box_a_idx, box_start_idx + 1], + output[batch_idx, box_a_idx, box_start_idx + 3]) + + # check if current box j is valid by calculating iou with + # all existing valid boxes + for k in parallel(j): Review comment: ```suggestion for k in range(j): ``` I found use serial loop here can actually improve performance a bit. ---------------------------------------------------------------- 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: us...@infra.apache.org