| 419 | } |
| 420 | |
| 421 | void ClIm2ColKernel::run_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue) |
| 422 | { |
| 423 | ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); |
| 424 | ARM_COMPUTE_ERROR_ON_MISMATCHING_WINDOWS(IClKernel::window(), window); |
| 425 | ARM_COMPUTE_ERROR_ON(tensors.empty()); |
| 426 | |
| 427 | // Get initial windows |
| 428 | // Collapse in order to have (SRC_DEPTH * BATCH_SIZE) on the 3rd dimension |
| 429 | Window window_collapsed = window.collapse_if_possible(ICLKernel::window(), Window::DimZ); |
| 430 | window_collapsed.set_dimension_step(Window::DimZ, 1); |
| 431 | |
| 432 | auto src = utils::cast::polymorphic_downcast<const ICLTensor *>(tensors.get_const_tensor(TensorType::ACL_SRC)); |
| 433 | auto dst = utils::cast::polymorphic_downcast<ICLTensor *>(tensors.get_tensor(TensorType::ACL_DST)); |
| 434 | ARM_COMPUTE_ERROR_ON_NULLPTR(src, dst); |
| 435 | |
| 436 | Window window_output; |
| 437 | window_output.use_tensor_dimensions(dst->info()->tensor_shape()); |
| 438 | |
| 439 | const Window first_slice_3d = window_collapsed.first_slice_window_3D(); |
| 440 | |
| 441 | Window slice = first_slice_3d; |
| 442 | Window slice_in = first_slice_3d; |
| 443 | Window slice_out = window_output.first_slice_window_2D(); |
| 444 | |
| 445 | if (_data_layout == DataLayout::NHWC) |
| 446 | { |
| 447 | const Window tmp_win = window.collapse_if_possible(ICLKernel::window(), 3); |
| 448 | const int num_batches = tmp_win[3].end(); |
| 449 | |
| 450 | slice.set(1, Window::Dimension(0, static_cast<int>(dst->info()->tensor_shape()[1]), 1)); |
| 451 | slice.set(2, Window::Dimension(0, static_cast<int>(num_batches), 1)); |
| 452 | } |
| 453 | else |
| 454 | { |
| 455 | slice.set(0, |
| 456 | Window::Dimension( |
| 457 | 0, static_cast<int>(ceil_to_multiple(_convolved_dims.first, _num_elems_processed_per_iteration)), |
| 458 | _num_elems_processed_per_iteration)); |
| 459 | slice.set(1, Window::Dimension(0, static_cast<int>(_convolved_dims.second), 1)); |
| 460 | // Note: In case of NCHW the 3rd dimension is already set collapsing the input window |
| 461 | } |
| 462 | |
| 463 | // Setup input slice |
| 464 | // The dimensions of the input are increased within the OpenCL kernel |
| 465 | slice_in.set(Window::DimX, Window::Dimension(0, 0, 0)); |
| 466 | slice_in.set(Window::DimY, Window::Dimension(0, 0, 0)); |
| 467 | slice_in.set(Window::DimZ, Window::Dimension(0, 0, 0)); |
| 468 | |
| 469 | // Setup output slice |
| 470 | // The dimensions of the output are increased within the OpenCL kernel |
| 471 | slice_out.set(Window::DimX, Window::Dimension(0, 0, 0)); |
| 472 | slice_out.set(Window::DimY, Window::Dimension(0, 0, 0)); |
| 473 | |
| 474 | unsigned int idx = num_arguments_per_3D_tensor() + |
| 475 | (_num_groups == 1 ? num_arguments_per_2D_tensor() : num_arguments_per_3D_tensor()); |
| 476 | _kernel.setArg<cl_uint>(idx++, static_cast<unsigned int>(src->info()->strides_in_bytes()[3])); |
| 477 | _kernel.setArg<cl_uint>(idx++, |
| 478 | static_cast<unsigned int>(dst->info()->strides_in_bytes()[((_num_groups == 1) ? 2 : 3)])); |
nothing calls this directly
no test coverage detected