| 170 | } |
| 171 | |
| 172 | void NEBatchToSpaceLayerKernel::run(const Window &window, const ThreadInfo &info) |
| 173 | { |
| 174 | ARM_COMPUTE_UNUSED(info); |
| 175 | ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); |
| 176 | ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(ICPPKernel::window(), window); |
| 177 | |
| 178 | if (_block_shape != nullptr) |
| 179 | { |
| 180 | // Retrieve the block shapes dynamically |
| 181 | _block_shape_x = *(reinterpret_cast<const int *>(_block_shape->ptr_to_element(0))); |
| 182 | _block_shape_y = *(reinterpret_cast<const int *>(_block_shape->ptr_to_element(1))); |
| 183 | } |
| 184 | |
| 185 | const int batch_size = _output->info()->dimension(3); |
| 186 | const int element_size = _output->info()->element_size(); |
| 187 | |
| 188 | Window slice_out = window.first_slice_window_3D(); |
| 189 | |
| 190 | int batch_id = 0; |
| 191 | // Main loop for NCHW and NHWC |
| 192 | if (_data_layout == DataLayout::NCHW) |
| 193 | { |
| 194 | do |
| 195 | { |
| 196 | Iterator out(_output, slice_out); |
| 197 | execute_window_loop( |
| 198 | slice_out, |
| 199 | [&](const Coordinates &id) |
| 200 | { |
| 201 | const int x = id.x(); |
| 202 | const int y = id.y(); |
| 203 | const int z = id.z(); |
| 204 | // Translate x, y to uncropped version |
| 205 | const int x_c = x + _crop_info.left; |
| 206 | const int y_c = y + _crop_info.top; |
| 207 | |
| 208 | const int in_batch = |
| 209 | batch_id + ((x_c % _block_shape_x) + (y_c % _block_shape_y) * _block_shape_x) * batch_size; |
| 210 | const int in_x = x_c / _block_shape_x; |
| 211 | const int in_y = y_c / _block_shape_y; |
| 212 | Coordinates input_coords{in_x, in_y, z, in_batch}; |
| 213 | memcpy(out.ptr(), _input->ptr_to_element(input_coords), element_size); |
| 214 | }, |
| 215 | out); |
| 216 | ++batch_id; |
| 217 | } while (window.slide_window_slice_3D(slice_out)); |
| 218 | } |
| 219 | else |
| 220 | { |
| 221 | // For NHWC we can perform a block copy on the Channel (first) dimension. Thus we do not need to iterate over this dimension |
| 222 | slice_out.set(0U, Window::Dimension(0U, 1U, 1U)); |
| 223 | do |
| 224 | { |
| 225 | Iterator out(_output, slice_out); |
| 226 | execute_window_loop( |
| 227 | slice_out, |
| 228 | [&](const Coordinates &id) |
| 229 | { |
nothing calls this directly
no test coverage detected