You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2019/11/13 06:11:09 UTC

[GitHub] [incubator-tvm] vinx13 commented on a change in pull request #4297: [TOPI][OP] Support Faster-RCNN Proposal OP on CPU

vinx13 commented on a change in pull request #4297: [TOPI][OP] Support Faster-RCNN Proposal OP on CPU
URL: https://github.com/apache/incubator-tvm/pull/4297#discussion_r345583973
 
 

 ##########
 File path: topi/python/topi/vision/rcnn/proposal.py
 ##########
 @@ -60,6 +61,261 @@ def reg_iou(x1, y1, x2, y2, dx1, dy1, dx2, dy2):
     pred_y2 = y2 + dy2
     return pred_x1, pred_y1, pred_x2, pred_y2
 
+def predict_bbox_ir(cls_prob_buf, bbox_pred_buf, im_info_buf, out_buf, scales, ratios,
+                    feature_stride, rpn_min_size, iou_loss):
+    """Predict bounding boxes based on anchors, scores and deltas.
+
+    Parameters
+    ----------
+    cls_prob_buf : tvm.schedule.Buffer
+        4-D with shape [batch, 2 * num_anchors, height, width]
+
+    bbox_pred_buf : tvm.schedule.Buffer
+        4-D with shape [batch, 4 * num_anchors, height, width]
+
+    im_info_buf : tvm.schedule.Buffer
+        2-D with shape [batch, 3]
+
+    out_buf : tvm.schedule.Buffer
+        3-D with shape [batch, num_bbox, 5]
+        The last dimension is in format of [w_start, h_start, w_end, h_end, score]
+
+    scales : list/tuple of float
+        Scales of anchor windoes.
+
+    ratios : list/tuple of float
+        Ratios of anchor windoes.
+
+    feature_stride : int
+        The size of the receptive field each unit in the convolution layer of the rpn, for example
+        the product of all stride's prior to this layer.
+
+    rpn_min_size : int
+        Minimum height or width in proposal.
+
+    iou_loss : bool
+        Usage of IoU loss.
+
+    Returns
+    -------
+    stmt : Stmt
+        The result IR statement.
+    """
+    batch, num_anchors, height, width = get_const_tuple(cls_prob_buf.shape)
+    num_anchors //= 2
+    ib = tvm.ir_builder.create()
+
+    p_score = ib.buffer_ptr(cls_prob_buf)
+    p_delta = ib.buffer_ptr(bbox_pred_buf)
+    p_im_info = ib.buffer_ptr(im_info_buf)
+    p_out = ib.buffer_ptr(out_buf)
+
+    idxm = tvm.indexmod
+    idxd = tvm.indexdiv
+
+    with ib.for_range(0, batch * height * width) as tid:
 
 Review comment:
   I met these issue too when I trying to migrate proposal CUDA op to hybrid, I think it’s okay to use ir builder for the time being

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services