| 337 | } |
| 338 | |
| 339 | void ClPool2dKernel::run_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue) |
| 340 | { |
| 341 | ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); |
| 342 | ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(ICLKernel::window(), window); |
| 343 | |
| 344 | unsigned int pool_stride_x = 0; |
| 345 | unsigned int pool_stride_y = 0; |
| 346 | std::tie(pool_stride_x, pool_stride_y) = _pool_info.pad_stride_info.stride(); |
| 347 | |
| 348 | const auto src = |
| 349 | utils::cast::polymorphic_downcast<const ICLTensor *>(tensors.get_const_tensor(TensorType::ACL_SRC)); |
| 350 | auto dst = utils::cast::polymorphic_downcast<ICLTensor *>(tensors.get_tensor(TensorType::ACL_DST_0)); |
| 351 | auto indices = utils::cast::polymorphic_downcast<ICLTensor *>(tensors.get_tensor(TensorType::ACL_DST_1)); |
| 352 | |
| 353 | // Collapse window |
| 354 | Window window_collapsed = window.collapse_if_possible(ICLKernel::window(), Window::DimZ); |
| 355 | |
| 356 | switch (_data_layout) |
| 357 | { |
| 358 | case DataLayout::NCHW: |
| 359 | { |
| 360 | Window slice = window_collapsed.first_slice_window_3D(); |
| 361 | do |
| 362 | { |
| 363 | // Set srcs |
| 364 | unsigned int idx = 0; |
| 365 | add_3D_tensor_argument(idx, src, slice); |
| 366 | add_3D_tensor_argument(idx, dst, slice); |
| 367 | if (indices && is_data_type_float(src->info()->data_type()) && (_pool_info.pool_size == Size2D(2, 2))) |
| 368 | { |
| 369 | add_3D_tensor_argument(idx, indices, slice); |
| 370 | } |
| 371 | enqueue(queue, *this, slice, lws_hint()); |
| 372 | } while (window_collapsed.slide_window_slice_3D(slice)); |
| 373 | break; |
| 374 | } |
| 375 | case DataLayout::NHWC: |
| 376 | { |
| 377 | const size_t batch_size = dst->info()->tensor_shape().total_size_upper(3); |
| 378 | |
| 379 | Window slice = window_collapsed.first_slice_window_4D(); |
| 380 | Window in_slice = window_collapsed.first_slice_window_4D(); |
| 381 | in_slice.set(Window::DimX, |
| 382 | Window::Dimension(0, src->info()->dimension(0), _num_elems_processed_per_iteration)); |
| 383 | in_slice.set(Window::DimY, Window::Dimension(0, src->info()->dimension(1), pool_stride_x)); |
| 384 | in_slice.set(Window::DimZ, Window::Dimension(0, src->info()->dimension(2), pool_stride_y)); |
| 385 | in_slice.set(3, Window::Dimension(0, batch_size, 1)); |
| 386 | do |
| 387 | { |
| 388 | // Set srcs |
| 389 | unsigned int idx = 0; |
| 390 | add_4D_tensor_argument(idx, src, in_slice); |
| 391 | add_4D_tensor_argument(idx, dst, slice); |
| 392 | if (indices && is_data_type_float(src->info()->data_type()) && |
| 393 | (_pool_info.pool_type == PoolingType::MAX) && (_pool_info.pool_size == Size2D(2, 2))) |
| 394 | { |
| 395 | add_4D_tensor_argument(idx, indices, slice); |
| 396 | } |
nothing calls this directly
no test coverage detected