24 #ifndef SRC_CORE_SVE_KERNELS_BOUNDINGBOXTRANFORM_IMPL_H
25 #define SRC_CORE_SVE_KERNELS_BOUNDINGBOXTRANFORM_IMPL_H
36 template <
typename input_data_type>
38 unsigned int roi_batch,
49 if ((region_end_x <= region_start_x) || (region_end_y <= region_start_y))
51 return input_data_type(0);
58 for (
int iy = 0; iy < grid_size_y; ++iy)
60 for (
int ix = 0; ix < grid_size_x; ++ix)
63 float y = region_start_y + (iy + 0.5) * bin_size_y / float(grid_size_y);
64 float x = region_start_x + (ix + 0.5) * bin_size_x / float(grid_size_x);
69 const int y_high = y_low + 1;
70 const int x_high = x_low + 1;
72 const float ly = y - y_low;
73 const float lx = x - x_low;
74 const float hy = 1. - ly;
75 const float hx = 1. - lx;
77 const float w1 = hy * hx;
78 const float w2 = hy * lx;
79 const float w3 = ly * hx;
80 const float w4 = ly * lx;
83 const auto data1 = *
reinterpret_cast<const input_data_type *
>(
85 const auto data2 = *
reinterpret_cast<const input_data_type *
>(
87 const auto data3 = *
reinterpret_cast<const input_data_type *
>(
89 const auto data4 = *
reinterpret_cast<const input_data_type *
>(
91 avg += w1 * data1 + w2 * data2 + w3 * data3 + w4 * data4;
95 const auto data1 = *
reinterpret_cast<const input_data_type *
>(
97 const auto data2 = *
reinterpret_cast<const input_data_type *
>(
99 const auto data3 = *
reinterpret_cast<const input_data_type *
>(
101 const auto data4 = *
reinterpret_cast<const input_data_type *
>(
103 avg += w1 * data1 + w2 * data2 + w3 * data3 + w4 * data4;
108 avg /= grid_size_x * grid_size_y;
109 return input_data_type(avg);
114 template <
typename input_data_type>
116 unsigned int roi_batch,
117 float region_start_x,
121 float region_start_y,
128 if ((region_end_x <= region_start_x) || (region_end_y <= region_start_y))
140 for (
int iy = 0; iy < grid_size_y; ++iy)
142 for (
int ix = 0; ix < grid_size_x; ++ix)
145 float y = region_start_y + (iy + 0.5) * bin_size_y / float(grid_size_y);
146 float x = region_start_x + (ix + 0.5) * bin_size_x / float(grid_size_x);
151 const int y_high = y_low + 1;
152 const int x_high = x_low + 1;
154 const float ly = y - y_low;
155 const float lx = x - x_low;
156 const float hy = 1. - ly;
157 const float hx = 1. - lx;
159 const float w1 = hy * hx;
160 const float w2 = hy * lx;
161 const float w3 = ly * hx;
162 const float w4 = ly * lx;
166 if (is_qasymm_signed)
184 avg += w1 * data1 + w2 * data2 + w3 * data3 + w4 * data4;
204 avg += w1 * data1 + w2 * data2 + w3 * data3 + w4 * data4;
209 if (is_qasymm_signed)
227 avg += w1 * data1 + w2 * data2 + w3 * data3 + w4 * data4;
247 avg += w1 * data1 + w2 * data2 + w3 * data3 + w4 * data4;
253 avg /= grid_size_x * grid_size_y;
255 input_data_type res = 0;
256 if (is_qasymm_signed)
269 const float region_start = p * bin_size + roi_anchor;
273 template <
typename input_data_type,
typename roi_data_type>
286 const int roi_list_start = window.
x().
start();
287 const int roi_list_end = window.
x().
end();
295 const int input_chanels =
input->info()->dimension(idx_depth);
302 const auto *rois_ptr =
reinterpret_cast<const roi_data_type *
>(rois->
buffer());
304 for (
int roi_indx = roi_list_start; roi_indx < roi_list_end; ++roi_indx)
306 const unsigned int roi_batch = rois_ptr[values_per_roi * roi_indx];
308 roi_data_type qx1 = rois_ptr[values_per_roi * roi_indx + 1];
309 roi_data_type qy1 = rois_ptr[values_per_roi * roi_indx + 2];
310 roi_data_type qx2 = rois_ptr[values_per_roi * roi_indx + 3];
311 roi_data_type qy2 = rois_ptr[values_per_roi * roi_indx + 4];
325 const float roi_dims_x = std::max((x2 - x1) * pool_info.
spatial_scale(), 1.0f);
326 const float roi_dims_y = std::max((y2 - y1) * pool_info.
spatial_scale(), 1.0f);
327 float bin_size_x = roi_dims_x / pool_info.
pooled_width();
331 for (
int ch = 0; ch < input_chanels; ++ch)
334 for (
int py = 0; py < pooled_h; ++py)
336 for (
int px = 0; px < pooled_w; ++px)
341 const float region_end_y =
343 const int roi_bin_grid_x =
345 const int roi_bin_grid_y =
347 input_data_type out_val(0);
350 out_val = roi_align_1x1_qasymm8<input_data_type>(
351 input, roi_batch, region_start_x, bin_size_x, roi_bin_grid_x, region_end_x, region_start_y,
356 out_val = roi_align_1x1<input_data_type>(
input, roi_batch, region_start_x, bin_size_x,
357 roi_bin_grid_x, region_end_x, region_start_y,
358 bin_size_y, roi_bin_grid_y, region_end_y, ch);
363 auto out_ptr =
reinterpret_cast<input_data_type *
>(
369 auto out_ptr =
reinterpret_cast<input_data_type *
>(
380 #endif //define SRC_CORE_SVE_KERNELS_BOUNDINGBOXTRANFORM_IMPL_H