Unverified Commit 131ba132 authored by Francisco Massa's avatar Francisco Massa Committed by GitHub
Browse files

Fix wrong clamping in RoIAlign with aligned=True (#2438)

* Fix wrong clamping in RoIAlign with aligned=True

* Fix silly mistake

* Bugfix pointed out during code-review
parent 0a8586c9
...@@ -141,9 +141,13 @@ void ROIAlignForward( ...@@ -141,9 +141,13 @@ void ROIAlignForward(
T roi_end_w = offset_rois[3] * spatial_scale - offset; T roi_end_w = offset_rois[3] * spatial_scale - offset;
T roi_end_h = offset_rois[4] * spatial_scale - offset; T roi_end_h = offset_rois[4] * spatial_scale - offset;
// Force malformed ROIs to be 1x1 T roi_width = roi_end_w - roi_start_w;
T roi_width = std::max(roi_end_w - roi_start_w, (T)1.); T roi_height = roi_end_h - roi_start_h;
T roi_height = std::max(roi_end_h - roi_start_h, (T)1.); if (!aligned) {
// Force malformed ROIs to be 1x1
roi_width = std::max(roi_width, (T)1.);
roi_height = std::max(roi_height, (T)1.);
}
T bin_size_h = static_cast<T>(roi_height) / static_cast<T>(pooled_height); T bin_size_h = static_cast<T>(roi_height) / static_cast<T>(pooled_height);
T bin_size_w = static_cast<T>(roi_width) / static_cast<T>(pooled_width); T bin_size_w = static_cast<T>(roi_width) / static_cast<T>(pooled_width);
...@@ -309,9 +313,13 @@ void ROIAlignBackward( ...@@ -309,9 +313,13 @@ void ROIAlignBackward(
T roi_end_w = offset_rois[3] * spatial_scale - offset; T roi_end_w = offset_rois[3] * spatial_scale - offset;
T roi_end_h = offset_rois[4] * spatial_scale - offset; T roi_end_h = offset_rois[4] * spatial_scale - offset;
// Force malformed ROIs to be 1x1 T roi_width = roi_end_w - roi_start_w;
T roi_width = std::max(roi_end_w - roi_start_w, (T)1.); T roi_height = roi_end_h - roi_start_h;
T roi_height = std::max(roi_end_h - roi_start_h, (T)1.); if (!aligned) {
// Force malformed ROIs to be 1x1
roi_width = std::max(roi_width, (T)1.);
roi_height = std::max(roi_height, (T)1.);
}
T bin_size_h = static_cast<T>(roi_height) / static_cast<T>(pooled_height); T bin_size_h = static_cast<T>(roi_height) / static_cast<T>(pooled_height);
T bin_size_w = static_cast<T>(roi_width) / static_cast<T>(pooled_width); T bin_size_w = static_cast<T>(roi_width) / static_cast<T>(pooled_width);
......
...@@ -91,9 +91,13 @@ __global__ void RoIAlignForward( ...@@ -91,9 +91,13 @@ __global__ void RoIAlignForward(
T roi_end_w = offset_rois[3] * spatial_scale - offset; T roi_end_w = offset_rois[3] * spatial_scale - offset;
T roi_end_h = offset_rois[4] * spatial_scale - offset; T roi_end_h = offset_rois[4] * spatial_scale - offset;
// Force malformed ROIs to be 1x1 T roi_width = roi_end_w - roi_start_w;
T roi_width = max(roi_end_w - roi_start_w, (T)1.); T roi_height = roi_end_h - roi_start_h;
T roi_height = max(roi_end_h - roi_start_h, (T)1.); if (!aligned) {
// Force malformed ROIs to be 1x1
roi_width = max(roi_width, (T)1.);
roi_height = max(roi_height, (T)1.);
}
T bin_size_h = static_cast<T>(roi_height) / static_cast<T>(pooled_height); T bin_size_h = static_cast<T>(roi_height) / static_cast<T>(pooled_height);
T bin_size_w = static_cast<T>(roi_width) / static_cast<T>(pooled_width); T bin_size_w = static_cast<T>(roi_width) / static_cast<T>(pooled_width);
...@@ -229,9 +233,13 @@ __global__ void RoIAlignBackward( ...@@ -229,9 +233,13 @@ __global__ void RoIAlignBackward(
T roi_end_w = offset_rois[3] * spatial_scale - offset; T roi_end_w = offset_rois[3] * spatial_scale - offset;
T roi_end_h = offset_rois[4] * spatial_scale - offset; T roi_end_h = offset_rois[4] * spatial_scale - offset;
// Force malformed ROIs to be 1x1 T roi_width = roi_end_w - roi_start_w;
T roi_width = max(roi_end_w - roi_start_w, (T)1.); T roi_height = roi_end_h - roi_start_h;
T roi_height = max(roi_end_h - roi_start_h, (T)1.); if (!aligned) {
// Force malformed ROIs to be 1x1
roi_width = max(roi_width, (T)1.);
roi_height = max(roi_height, (T)1.);
}
T bin_size_h = static_cast<T>(roi_height) / static_cast<T>(pooled_height); T bin_size_h = static_cast<T>(roi_height) / static_cast<T>(pooled_height);
T bin_size_w = static_cast<T>(roi_width) / static_cast<T>(pooled_width); T bin_size_w = static_cast<T>(roi_width) / static_cast<T>(pooled_width);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment