diff --git a/modules/detectron/ps_roi_pool_op.cu b/modules/detectron/ps_roi_pool_op.cu index 53844b1aa04122..2e713a786fc695 100644 --- a/modules/detectron/ps_roi_pool_op.cu +++ b/modules/detectron/ps_roi_pool_op.cu @@ -130,6 +130,7 @@ __global__ void PSRoIPoolForward( T bin_size_h = roi_height / static_cast(pooled_height); T bin_size_w = roi_width / static_cast(pooled_width); + // Add roi offsets and clip to input boundaries int hstart = floor( static_cast(ph) * bin_size_h + roi_start_h); int wstart = floor( @@ -138,7 +139,7 @@ __global__ void PSRoIPoolForward( static_cast(ph + 1) * bin_size_h + roi_start_h); int wend = ceil( static_cast(pw + 1) * bin_size_w + roi_start_w); - // Add roi offsets and clip to input boundaries + hstart = min(max(hstart, 0), height); hend = min(max(hend, 0), height); wstart = min(max(wstart, 0),width);