1- // Tencent is pleased to support the open source community by making ncnn available.
1+ // Tencent is pleased to support the open source community by making ncnn available.
22//
33// Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
44//
@@ -116,7 +116,7 @@ void detectron2_pre_calc_for_bilinear_interpolate(
116116
117117 T ly = y - y_low;
118118 T lx = x - x_low;
119- T hy = 1 . - ly, hx = 1 . - lx;
119+ T hy = (T)( 1 . - ly) , hx = (T)( 1 . - lx) ;
120120 T w1 = hy * hx, w2 = hy * lx, w3 = ly * hx, w4 = ly * lx;
121121
122122 // save weights and indices
@@ -163,8 +163,8 @@ void original_pre_calc_for_bilinear_interpolate(
163163 hend = std::min (std::max (hend, 0 .f ), (float )height);
164164 wend = std::min (std::max (wend, 0 .f ), (float )width);
165165
166- int bin_grid_h = sampling_ratio > 0 ? sampling_ratio : ceil (hend - hstart);
167- int bin_grid_w = sampling_ratio > 0 ? sampling_ratio : ceil (wend - wstart);
166+ int bin_grid_h = ( int )( sampling_ratio > 0 ? sampling_ratio : ceil (hend - hstart) );
167+ int bin_grid_w = ( int )( sampling_ratio > 0 ? sampling_ratio : ceil (wend - wstart) );
168168
169169 for (int by = 0 ; by < bin_grid_h; by++)
170170 {
@@ -173,9 +173,9 @@ void original_pre_calc_for_bilinear_interpolate(
173173 for (int bx = 0 ; bx < bin_grid_w; bx++)
174174 {
175175 float x = wstart + (bx + 0 .5f ) * bin_size_w / (float )bin_grid_w;
176- int x0 = x;
176+ int x0 = ( int ) x;
177177 int x1 = x0 + 1 ;
178- int y0 = y;
178+ int y0 = ( int ) y;
179179 int y1 = y0 + 1 ;
180180
181181 float a0 = x1 - x;
@@ -261,8 +261,8 @@ int ROIAlign_x86::forward(const std::vector<Mat>& bottom_blobs, std::vector<Mat>
261261 if (version == 0 )
262262 {
263263 // original version
264- int roi_bin_grid_h = sampling_ratio > 0 ? sampling_ratio : ceil (roi_height / pooled_height);
265- int roi_bin_grid_w = sampling_ratio > 0 ? sampling_ratio : ceil (roi_width / pooled_width);
264+ int roi_bin_grid_h = ( int )( sampling_ratio > 0 ? sampling_ratio : ceil (roi_height / pooled_height) );
265+ int roi_bin_grid_w = ( int )( sampling_ratio > 0 ? sampling_ratio : ceil (roi_width / pooled_width) );
266266 std::vector<PreCalc<float > > pre_calc (
267267 roi_bin_grid_h * roi_bin_grid_w * pooled_width * pooled_height);
268268 original_pre_calc_for_bilinear_interpolate (
@@ -301,8 +301,8 @@ int ROIAlign_x86::forward(const std::vector<Mat>& bottom_blobs, std::vector<Mat>
301301 hend = std::min (std::max (hend, 0 .f ), (float )height);
302302 wend = std::min (std::max (wend, 0 .f ), (float )width);
303303
304- int bin_grid_h = sampling_ratio > 0 ? sampling_ratio : ceil (hend - hstart);
305- int bin_grid_w = sampling_ratio > 0 ? sampling_ratio : ceil (wend - wstart);
304+ int bin_grid_h = ( int )( sampling_ratio > 0 ? sampling_ratio : ceil (hend - hstart) );
305+ int bin_grid_w = ( int )( sampling_ratio > 0 ? sampling_ratio : ceil (wend - wstart) );
306306
307307 bool is_empty = (hend <= hstart) || (wend <= wstart);
308308 int area = bin_grid_h * bin_grid_w;
@@ -327,10 +327,10 @@ int ROIAlign_x86::forward(const std::vector<Mat>& bottom_blobs, std::vector<Mat>
327327 else if (version == 1 )
328328 {
329329 // the version in detectron 2
330- int roi_bin_grid_h = sampling_ratio > 0 ? sampling_ratio : ceil (roi_height / pooled_height);
331- int roi_bin_grid_w = sampling_ratio > 0 ? sampling_ratio : ceil (roi_width / pooled_width);
330+ int roi_bin_grid_h = ( int )( sampling_ratio > 0 ? sampling_ratio : ceil (roi_height / pooled_height) );
331+ int roi_bin_grid_w = ( int )( sampling_ratio > 0 ? sampling_ratio : ceil (roi_width / pooled_width) );
332332
333- const float count = std::max (roi_bin_grid_h * roi_bin_grid_w, 1 );
333+ const float count = ( float ) std::max (roi_bin_grid_h * roi_bin_grid_w, 1 );
334334
335335 std::vector<PreCalc<float > > pre_calc (
336336 roi_bin_grid_h * roi_bin_grid_w * pooled_width * pooled_height);
0 commit comments