Jerryzcn commented on a change in pull request #16619: add aligned roi 
introduced in Detectron2
URL: https://github.com/apache/incubator-mxnet/pull/16619#discussion_r339256359
 
 

 ##########
 File path: src/operator/contrib/mrcnn_mask_target.cu
 ##########
 @@ -135,14 +136,21 @@ __device__ void RoIAlignForward(
 
     const T* offset_rois = rois + batch_idx * (4 * num_rois) + n * 4;
     // Do not using rounding; this implementation detail is critical
-    T roi_start_w = offset_rois[0];
-    T roi_start_h = offset_rois[1];
-    T roi_end_w = offset_rois[2];
-    T roi_end_h = offset_rois[3];
+    T roi_offset = continuous_coordinate ? static_cast<T>(0.5) : 
static_cast<T>(0);
+    T roi_start_w = offset_rois[0] - roi_offset;
+    T roi_start_h = offset_rois[1] - roi_offset;
+    T roi_end_w = offset_rois[2] - roi_offset;
+    T roi_end_h = offset_rois[3] - roi_offset;
+
+    T roi_width = roi_end_w - roi_start_w;
+    T roi_height = roi_end_h - roi_start_h;
 
     // Force malformed ROIs to be 1x1
-    T roi_width = max(roi_end_w - roi_start_w, (T)1.);
-    T roi_height = max(roi_end_h - roi_start_h, (T)1.);
+    if (!continuous_coordinate) {  // backward compatiblity
 
 Review comment:
   save computation. pytorch doesn't do it so I just copied it.

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