| 113 | } |
| 114 | |
| 115 | void NESpaceToDepthLayerKernel::run(const Window &window, const ThreadInfo &info) |
| 116 | { |
| 117 | ARM_COMPUTE_UNUSED(info); |
| 118 | ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); |
| 119 | ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(ICPPKernel::window(), window); |
| 120 | |
| 121 | const int channel_idx = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::CHANNEL); |
| 122 | const int element_size = _input->info()->element_size(); |
| 123 | |
| 124 | const size_t channel_size = _input->info()->dimension(channel_idx); |
| 125 | |
| 126 | Window slice_out = window.first_slice_window_3D(); |
| 127 | |
| 128 | int batch_id = 0; |
| 129 | |
| 130 | // Main loop for NCHW and NHWC |
| 131 | if (_data_layout == DataLayout::NCHW) |
| 132 | { |
| 133 | do |
| 134 | { |
| 135 | Iterator out(_output, slice_out); |
| 136 | execute_window_loop( |
| 137 | slice_out, |
| 138 | [&](const Coordinates &id) |
| 139 | { |
| 140 | const size_t channel_id = id.z(); |
| 141 | const size_t in_x = id.x() * _block_shape + (channel_id / channel_size) % _block_shape; |
| 142 | const size_t in_y = id.y() * _block_shape + (channel_id / channel_size) / _block_shape; |
| 143 | const int z = channel_id % channel_size; |
| 144 | Coordinates input_coords{in_x, in_y, z, batch_id}; |
| 145 | memcpy(out.ptr(), _input->ptr_to_element(input_coords), element_size); |
| 146 | }, |
| 147 | out); |
| 148 | ++batch_id; |
| 149 | } while (window.slide_window_slice_3D(slice_out)); |
| 150 | } |
| 151 | else |
| 152 | { |
| 153 | do |
| 154 | { |
| 155 | Iterator out(_output, slice_out); |
| 156 | execute_window_loop( |
| 157 | slice_out, |
| 158 | [&](const Coordinates &id) |
| 159 | { |
| 160 | const size_t channel_id = id.x(); |
| 161 | const size_t in_x = id.y() * _block_shape + (channel_id / channel_size) % _block_shape; |
| 162 | const size_t in_y = id.z() * _block_shape + (channel_id / channel_size) / _block_shape; |
| 163 | const int z = channel_id % channel_size; |
| 164 | Coordinates input_coords{z, in_x, in_y, batch_id}; |
| 165 | memcpy(out.ptr(), _input->ptr_to_element(input_coords), element_size); |
| 166 | }, |
| 167 | out); |
| 168 | ++batch_id; |
| 169 | } while (window.slide_window_slice_3D(slice_out)); |
| 170 | } |
| 171 | } |
| 172 | } // namespace arm_compute |
nothing calls this directly
no test coverage detected