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

Method configure_output_shape

src/core/NEON/kernels/NECropKernel.cpp:262–323  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

260}
261
262void NECropKernel::configure_output_shape()
263{
264 // _crop_box_ind is used to index _crop_boxes and retrieve the appropriate crop box.
265 // The crop box is specified by normalized coordinates [y0, x0, y1, x1].
266 const float x0 = *reinterpret_cast<const float *>(_crop_boxes->ptr_to_element(Coordinates(1, _crop_box_ind)));
267 const float y0 = *reinterpret_cast<const float *>(_crop_boxes->ptr_to_element(Coordinates(0, _crop_box_ind)));
268 const float x1 = *reinterpret_cast<const float *>(_crop_boxes->ptr_to_element(Coordinates(3, _crop_box_ind)));
269 const float y1 = *reinterpret_cast<const float *>(_crop_boxes->ptr_to_element(Coordinates(2, _crop_box_ind)));
270 // The normalized coordiantes are scaled to retrieve the floating point image coordinates which are rounded to integers.
271 _start = Coordinates(std::floor(x0 * (_input->info()->tensor_shape()[1] - 1) + 0.5f),
272 std::floor(y0 * (_input->info()->tensor_shape()[2] - 1) + 0.5f));
273 _end = Coordinates(std::floor(x1 * (_input->info()->tensor_shape()[1] - 1) + 0.5f),
274 std::floor(y1 * (_input->info()->tensor_shape()[2] - 1) + 0.5f));
275 const TensorShape out_shape(_input->info()->tensor_shape()[0], abs(_end[0] - _start[0]) + 1,
276 abs(_end[1] - _start[1]) + 1);
277 _output->info()->set_tensor_shape(out_shape);
278
279 bool is_width_flipped = _end[0] < _start[0];
280 bool is_height_flipped = _end[1] < _start[1];
281 if (is_height_flipped)
282 {
283 _rows_out_of_bounds[0] = _start[1] >= static_cast<int32_t>(_input->info()->dimension(2))
284 ? std::min(static_cast<uint32_t>(_start[1] - _input->info()->dimension(2) + 1),
285 static_cast<uint32_t>(_output->info()->dimension(2)))
286 : 0;
287 _rows_out_of_bounds[1] = _end[1] < 0 ? std::min(static_cast<uint32_t>(-_end[1]),
288 static_cast<uint32_t>(_output->info()->dimension(2)))
289 : 0;
290 }
291 else
292 {
293 _rows_out_of_bounds[0] = _start[1] < 0 ? std::min(static_cast<uint32_t>(-_start[1]),
294 static_cast<uint32_t>(_output->info()->dimension(2)))
295 : 0;
296 _rows_out_of_bounds[1] = _end[1] >= static_cast<int32_t>(_input->info()->dimension(2))
297 ? std::min(static_cast<uint32_t>(_end[1] - _input->info()->dimension(2) + 1),
298 static_cast<uint32_t>(_output->info()->dimension(2)))
299 : 0;
300 }
301 if (is_width_flipped)
302 {
303 _cols_out_of_bounds[0] = _start[0] >= static_cast<int32_t>(_input->info()->dimension(1))
304 ? std::min(static_cast<uint32_t>(_start[0] - _input->info()->dimension(1) + 1),
305 static_cast<uint32_t>(_output->info()->dimension(1)))
306 : 0;
307 _cols_out_of_bounds[1] = _end[0] < 0 ? std::min(static_cast<uint32_t>(-_end[0]),
308 static_cast<uint32_t>(_output->info()->dimension(1)))
309 : 0;
310 }
311 else
312 {
313 _cols_out_of_bounds[0] = _start[0] < 0 ? std::min(static_cast<uint32_t>(-_start[0]),
314 static_cast<uint32_t>(_output->info()->dimension(1)))
315 : 0;
316 _cols_out_of_bounds[1] = _end[0] >= static_cast<int32_t>(_input->info()->dimension(1))
317 ? std::min(static_cast<uint32_t>(_end[0] - _input->info()->dimension(1) + 1),
318 static_cast<uint32_t>(_output->info()->dimension(1)))
319 : 0;

Callers 1

runMethod · 0.80

Calls 7

floorFunction · 0.85
absFunction · 0.85
ptr_to_elementMethod · 0.80
CoordinatesClass · 0.70
calculate_max_windowFunction · 0.50
infoMethod · 0.45
dimensionMethod · 0.45

Tested by

no test coverage detected