MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / run

Method run

src/core/NEON/kernels/NEROIPoolingLayerKernel.cpp:183–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

181}
182
183void NEROIPoolingLayerKernel::run(const Window &window, const ThreadInfo &info)
184{
185 ARM_COMPUTE_UNUSED(info);
186 ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this);
187 ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(INEKernel::window(), window);
188
189 const size_t values_per_roi = _rois->info()->dimension(0);
190
191 const int roi_list_start = window.x().start();
192 const int roi_list_end = window.x().end();
193 const int width = _input->info()->dimension(Window::DimX);
194 const int height = _input->info()->dimension(Window::DimY);
195 const int fms = _input->info()->dimension(Window::DimZ);
196 const int pooled_w = _pool_info.pooled_width();
197 const int pooled_h = _pool_info.pooled_height();
198 const float spatial_scale = _pool_info.spatial_scale();
199
200 const auto *rois_ptr = reinterpret_cast<const uint16_t *>(_rois->buffer());
201 const auto data_type = _input->info()->data_type();
202
203 for (int roi_indx = roi_list_start; roi_indx < roi_list_end; ++roi_indx)
204 {
205 const unsigned int roi_batch = rois_ptr[values_per_roi * roi_indx];
206 const auto x1 = rois_ptr[values_per_roi * roi_indx + 1];
207 const auto y1 = rois_ptr[values_per_roi * roi_indx + 2];
208 const auto x2 = rois_ptr[values_per_roi * roi_indx + 3];
209 const auto y2 = rois_ptr[values_per_roi * roi_indx + 4];
210
211 // Scale ROI
212 const int roi_anchor_x = support::cpp11::round(x1 * spatial_scale);
213 const int roi_anchor_y = support::cpp11::round(y1 * spatial_scale);
214 const int roi_width = std::max(support::cpp11::round((x2 - x1) * spatial_scale), 1.f);
215 const int roi_height = std::max(support::cpp11::round((y2 - y1) * spatial_scale), 1.f);
216
217 // Iterate through all feature maps
218 for (int fm = 0; fm < fms; ++fm)
219 {
220 // Iterate through all output pixels
221 for (int py = 0; py < pooled_h; ++py)
222 {
223 for (int px = 0; px < pooled_w; ++px)
224 {
225 auto region_start_x = static_cast<int>(std::floor((static_cast<float>(px) / pooled_w) * roi_width));
226 auto region_end_x =
227 static_cast<int>(std::floor((static_cast<float>(px + 1) / pooled_w) * roi_width));
228 auto region_start_y =
229 static_cast<int>(std::floor((static_cast<float>(py) / pooled_h) * roi_height));
230 auto region_end_y =
231 static_cast<int>(std::floor((static_cast<float>(py + 1) / pooled_h) * roi_height));
232
233 region_start_x = std::min(std::max(region_start_x + roi_anchor_x, 0), width);
234 region_end_x = std::min(std::max(region_end_x + roi_anchor_x, 0), width);
235 region_start_y = std::min(std::max(region_start_y + roi_anchor_y, 0), height);
236 region_end_y = std::min(std::max(region_end_y + roi_anchor_y, 0), height);
237
238 switch (data_type)
239 {
240 case DataType::F32:

Callers

nothing calls this directly

Calls 12

floorFunction · 0.85
pooled_widthMethod · 0.80
pooled_heightMethod · 0.80
roundFunction · 0.50
dimensionMethod · 0.45
infoMethod · 0.45
startMethod · 0.45
xMethod · 0.45
endMethod · 0.45
spatial_scaleMethod · 0.45
bufferMethod · 0.45
data_typeMethod · 0.45

Tested by

no test coverage detected