George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 1 | /* |
Michele Di Giorgio | d9eaf61 | 2020-07-08 11:12:57 +0100 | [diff] [blame] | 2 | * Copyright (c) 2019-2020 Arm Limited. |
George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to |
| 8 | * deal in the Software without restriction, including without limitation the |
| 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 10 | * sell copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in all |
| 14 | * copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | * SOFTWARE. |
| 23 | */ |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 24 | #include "arm_compute/runtime/CL/functions/CLCropResize.h" |
George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 25 | |
| 26 | #include "arm_compute/core/CL/CLHelpers.h" |
George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 27 | #include "arm_compute/runtime/CL/CLScheduler.h" |
Sang-Hoon Park | bef7fa2 | 2020-10-21 15:58:54 +0100 | [diff] [blame] | 28 | #include "src/core/CL/kernels/CLCopyKernel.h" |
| 29 | #include "src/core/CL/kernels/CLCropKernel.h" |
| 30 | #include "src/core/CL/kernels/CLFillBorderKernel.h" |
| 31 | #include "src/core/CL/kernels/CLMemsetKernel.h" |
Sang-Hoon Park | 68dd25f | 2020-10-19 16:00:11 +0100 | [diff] [blame] | 32 | #include "src/core/helpers/AutoConfiguration.h" |
| 33 | #include "src/core/helpers/WindowHelpers.h" |
| 34 | |
George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 35 | #include <cstddef> |
| 36 | |
| 37 | namespace arm_compute |
| 38 | { |
| 39 | namespace |
| 40 | { |
| 41 | inline void configure_crop(const ICLTensor *input, ICLTensor *crop_boxes, ICLTensor *box_ind, ICLTensor *output, uint32_t crop_box_ind, Coordinates &start, Coordinates &end, uint32_t &batch_index) |
| 42 | { |
| 43 | batch_index = *(reinterpret_cast<int32_t *>(box_ind->ptr_to_element(Coordinates(crop_box_ind)))); |
| 44 | |
| 45 | // _crop_box_ind is used to index crop_boxes and retrieve the appropriate crop box. |
| 46 | // The crop box is specified by normalized coordinates [y0, x0, y1, x1]. |
| 47 | const float x0 = *reinterpret_cast<const float *>(crop_boxes->ptr_to_element(Coordinates(1, crop_box_ind))); |
| 48 | const float y0 = *reinterpret_cast<const float *>(crop_boxes->ptr_to_element(Coordinates(0, crop_box_ind))); |
| 49 | const float x1 = *reinterpret_cast<const float *>(crop_boxes->ptr_to_element(Coordinates(3, crop_box_ind))); |
| 50 | const float y1 = *reinterpret_cast<const float *>(crop_boxes->ptr_to_element(Coordinates(2, crop_box_ind))); |
| 51 | // The normalized coordinates are scaled to retrieve the floating point image coordinates which are rounded to integers. |
| 52 | start = Coordinates(std::floor(x0 * (input->info()->tensor_shape()[1] - 1) + 0.5f), |
| 53 | std::floor(y0 * (input->info()->tensor_shape()[2] - 1) + 0.5f)); |
| 54 | end = Coordinates(std::floor(x1 * (input->info()->tensor_shape()[1] - 1) + 0.5f), |
| 55 | std::floor(y1 * (input->info()->tensor_shape()[2] - 1) + 0.5f)); |
Michalis Spyrou | fae513c | 2019-10-16 17:41:33 +0100 | [diff] [blame] | 56 | const TensorShape out_shape(input->info()->tensor_shape()[0], static_cast<uint32_t>(abs(end[0] - start[0])) + 1, static_cast<uint32_t>(abs(end[1] - start[1])) + 1); |
George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 57 | output->info()->set_tensor_shape(out_shape); |
| 58 | } |
George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 59 | } // namespace |
| 60 | |
| 61 | CLCropResize::CLCropResize() |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 62 | : _input(nullptr), _boxes(nullptr), _box_ind(nullptr), _output(nullptr), _num_boxes(0), _method(), _extrapolation_value(0), _scale(), _copy(), _crop_results(), _scaled_results(), _internal_kernels() |
George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 63 | { |
| 64 | } |
| 65 | |
Sang-Hoon Park | bef7fa2 | 2020-10-21 15:58:54 +0100 | [diff] [blame] | 66 | CLCropResize::~CLCropResize() = default; |
| 67 | |
George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 68 | Status CLCropResize::validate(const ITensorInfo *input, ITensorInfo *boxes, ITensorInfo *box_ind, const ITensorInfo *output, |
| 69 | Coordinates2D crop_size, InterpolationPolicy method, float extrapolation_value) |
| 70 | { |
| 71 | ARM_COMPUTE_RETURN_ERROR_ON(crop_size.x <= 0 || crop_size.y <= 0); |
| 72 | ARM_COMPUTE_RETURN_ERROR_ON(method == InterpolationPolicy::AREA); |
| 73 | ARM_COMPUTE_RETURN_ERROR_ON(boxes->tensor_shape()[0] != 4); |
| 74 | ARM_COMPUTE_RETURN_ERROR_ON(boxes->tensor_shape()[1] != box_ind->tensor_shape()[0]); |
| 75 | TensorInfo temp_info; |
| 76 | ARM_COMPUTE_RETURN_ON_ERROR(CLCropKernel::validate(input->clone().get(), &temp_info, { 0, 0 }, { 1, 1 }, input->dimension(3) - 1, extrapolation_value)); |
| 77 | if(output->total_size() > 0) |
| 78 | { |
| 79 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_NOT_IN(output, DataType::F32); |
| 80 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_LAYOUT(input, output); |
| 81 | TensorShape out_shape(input->tensor_shape()[0], crop_size.x, crop_size.y, boxes->tensor_shape()[1]); |
| 82 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(output->tensor_shape(), out_shape); |
| 83 | } |
| 84 | return Status{}; |
| 85 | } |
| 86 | |
| 87 | void CLCropResize::configure(const ICLTensor *input, ICLTensor *boxes, ICLTensor *box_ind, ICLTensor *output, Coordinates2D crop_size, |
| 88 | InterpolationPolicy method, float extrapolation_value) |
| 89 | { |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 90 | configure(CLKernelLibrary::get().get_compile_context(), input, boxes, box_ind, output, crop_size, method, extrapolation_value); |
| 91 | } |
| 92 | |
| 93 | void CLCropResize::configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *boxes, ICLTensor *box_ind, ICLTensor *output, Coordinates2D crop_size, |
| 94 | InterpolationPolicy method, float extrapolation_value) |
| 95 | { |
| 96 | ARM_COMPUTE_ERROR_ON_NULLPTR(input, output, boxes, box_ind); |
George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 97 | ARM_COMPUTE_ERROR_THROW_ON(CLCropResize::validate(input->info(), boxes->info(), box_ind->info(), output->info(), crop_size, method, extrapolation_value)); |
| 98 | |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 99 | TensorShape output_shape = TensorShape(input->info()->tensor_shape()[0], crop_size.x, crop_size.y, boxes->info()->tensor_shape()[1]); |
| 100 | auto_init_if_empty(*output->info(), output_shape, 1, DataType::F32); |
| 101 | |
George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 102 | _num_boxes = boxes->info()->tensor_shape()[1]; |
| 103 | TensorShape out_shape(input->info()->tensor_shape()[0], crop_size.x, crop_size.y); |
| 104 | |
| 105 | _input = input; |
| 106 | _boxes = boxes; |
| 107 | _box_ind = box_ind; |
| 108 | _output = output; |
| 109 | _method = method; |
| 110 | _extrapolation_value = extrapolation_value; |
| 111 | |
| 112 | // For each crop box: |
| 113 | // - The initial cropped image is produced as specified by boxes[i] from the 3D image input[box_ind[i]]. |
| 114 | // Possibly using a CLCropKernel and up to four CLMemsetKernels. |
| 115 | // - A tensor is required to hold this initial cropped image. |
| 116 | // - A scale function is used to resize the cropped image to the size specified by crop_size. |
| 117 | // - A tensor is required to hold the final scaled image before it is copied into the 4D output |
| 118 | // that will hold all final cropped and scaled 3D images using CLCopyKernel. |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 119 | |
| 120 | // The contents of _boxes and _box_ind are required to calculate the shape |
| 121 | // of the initial cropped image and thus are required to configure the |
| 122 | // kernels used for cropping and scaling. |
| 123 | _boxes->map(CLScheduler::get().queue()); |
| 124 | _box_ind->map(CLScheduler::get().queue()); |
| 125 | for(unsigned int num_box = 0; num_box < _num_boxes; ++num_box) |
George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 126 | { |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 127 | auto crop_tensor = std::make_unique<CLTensor>(); |
George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 128 | TensorInfo crop_result_info(1, DataType::F32); |
| 129 | crop_result_info.set_data_layout(DataLayout::NHWC); |
Michalis Spyrou | a4f378d | 2019-04-26 14:54:54 +0100 | [diff] [blame] | 130 | crop_tensor->allocator()->init(crop_result_info); |
| 131 | _crop_results.emplace_back(std::move(crop_tensor)); |
George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 132 | |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 133 | auto scale_tensor = std::make_unique<CLTensor>(); |
George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 134 | TensorInfo scaled_result_info(out_shape, 1, DataType::F32); |
| 135 | scaled_result_info.set_data_layout(DataLayout::NHWC); |
Michalis Spyrou | a4f378d | 2019-04-26 14:54:54 +0100 | [diff] [blame] | 136 | scale_tensor->allocator()->init(scaled_result_info); |
| 137 | _scaled_results.emplace_back(std::move(scale_tensor)); |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 138 | |
| 139 | // Size of the crop box in _boxes has to be given before the configure |
| 140 | uint32_t batch_index; |
| 141 | Coordinates start{}; |
| 142 | Coordinates end{}; |
| 143 | configure_crop(_input, _boxes, _box_ind, _crop_results[num_box].get(), num_box, start, end, batch_index); |
| 144 | |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 145 | auto scale_kernel = std::make_unique<CLScale>(); |
Sang-Hoon Park | ccd9496 | 2020-06-09 12:09:24 +0100 | [diff] [blame] | 146 | scale_kernel->configure(compile_context, _crop_results[num_box].get(), _scaled_results[num_box].get(), ScaleKernelInfo{ _method, BorderMode::CONSTANT, PixelValue(_extrapolation_value), SamplingPolicy::TOP_LEFT }); |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 147 | _scale.emplace_back(std::move(scale_kernel)); |
| 148 | |
| 149 | Window win = calculate_max_window(*_output->info()); |
| 150 | win.set(3, Window::Dimension(num_box, num_box + 1, 1)); |
| 151 | |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 152 | auto copy_kernel = std::make_unique<CLCopyKernel>(); |
SiCong Li | 3580c75 | 2020-10-14 17:00:56 +0100 | [diff] [blame] | 153 | copy_kernel->configure(compile_context, _scaled_results[num_box].get(), _output, &win); |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 154 | _copy.emplace_back(std::move(copy_kernel)); |
| 155 | |
| 156 | _crop_results[num_box]->allocator()->allocate(); |
| 157 | _scaled_results[num_box]->allocator()->allocate(); |
| 158 | |
| 159 | bool is_width_flipped = end[0] < start[0]; |
| 160 | bool is_height_flipped = end[1] < start[1]; |
| 161 | /** The number of rows out of bounds at the start and end of _crop_results[num_box].get(). */ |
| 162 | std::array<int32_t, 2> rows_out_of_bounds{ 0 }; |
| 163 | /** The number of columns out of bounds at the start and end of _crop_results[num_box].get(). */ |
| 164 | std::array<int32_t, 2> cols_out_of_bounds{ 0 }; |
| 165 | if(is_height_flipped) |
| 166 | { |
| 167 | rows_out_of_bounds[0] = start[1] >= static_cast<int32_t>(_input->info()->dimension(2)) ? std::min(start[1] - _input->info()->dimension(2) + 1, _crop_results[num_box].get()->info()->dimension(2)) : 0; |
| 168 | rows_out_of_bounds[1] = end[1] < 0 ? std::min(-end[1], static_cast<int32_t>(_crop_results[num_box].get()->info()->dimension(2))) : 0; |
| 169 | } |
| 170 | else |
| 171 | { |
| 172 | rows_out_of_bounds[0] = start[1] < 0 ? std::min(-start[1], static_cast<int32_t>(_crop_results[num_box].get()->info()->dimension(2))) : 0; |
| 173 | rows_out_of_bounds[1] = end[1] >= static_cast<int32_t>(_input->info()->dimension(2)) ? std::min(end[1] - _input->info()->dimension(2) + 1, _crop_results[num_box].get()->info()->dimension(2)) : 0; |
| 174 | } |
| 175 | if(is_width_flipped) |
| 176 | { |
| 177 | cols_out_of_bounds[0] = start[0] >= static_cast<int32_t>(_input->info()->dimension(1)) ? std::min(start[0] - _input->info()->dimension(1) + 1, _crop_results[num_box].get()->info()->dimension(1)) : 0; |
| 178 | cols_out_of_bounds[1] = end[0] < 0 ? std::min(-end[0], static_cast<int32_t>(_crop_results[num_box].get()->info()->dimension(1))) : 0; |
| 179 | } |
| 180 | else |
| 181 | { |
| 182 | cols_out_of_bounds[0] = start[0] < 0 ? std::min(-start[0], static_cast<int32_t>(_crop_results[num_box].get()->info()->dimension(1))) : 0; |
| 183 | cols_out_of_bounds[1] = end[0] >= static_cast<int32_t>(_input->info()->dimension(1)) ? std::min(end[0] - _input->info()->dimension(1) + 1, _crop_results[num_box].get()->info()->dimension(1)) : 0; |
| 184 | } |
| 185 | |
| 186 | Window full_window = calculate_max_window(*_crop_results[num_box].get()->info()); |
| 187 | |
| 188 | // Full _crop_results[num_box].get() window: |
| 189 | // -------------------------------- |
| 190 | // | Out of bounds | |
| 191 | // | rows before | |
| 192 | // |------------------------------| |
| 193 | // | Out of | In | Out of | |
| 194 | // | bounds | bounds | bounds | |
| 195 | // | cols | elements | cols | |
| 196 | // | before | copied | after | |
| 197 | // | | from input | | |
| 198 | // |------------------------------| |
| 199 | // | Out of bounds | |
| 200 | // | rows after | |
| 201 | // |------------------------------| |
| 202 | // Use a separate _crop_results[num_box].get() window for each section of the full _crop_results[num_box].get() window. |
| 203 | // Fill all _crop_results[num_box].get() rows that have no elements that are within the input bounds |
| 204 | // with the extrapolation value using memset. |
| 205 | // First for the rows before the in bounds rows. |
| 206 | if(rows_out_of_bounds[0] > 0) |
| 207 | { |
| 208 | Window slice_fill_rows_before(full_window); |
| 209 | slice_fill_rows_before.set(2, Window::Dimension(0, rows_out_of_bounds[0], 1)); |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 210 | auto kernel = std::make_unique<CLMemsetKernel>(); |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 211 | kernel->configure(compile_context, _crop_results[num_box].get(), extrapolation_value, &slice_fill_rows_before); |
| 212 | _internal_kernels.push_back(std::move(kernel)); |
| 213 | } |
| 214 | |
| 215 | Window slice_in(full_window); |
| 216 | slice_in.set(2, Window::Dimension(rows_out_of_bounds[0], _crop_results[num_box].get()->info()->dimension(2) - rows_out_of_bounds[1], 1)); |
| 217 | slice_in.set(1, Window::Dimension(cols_out_of_bounds[0], _crop_results[num_box].get()->info()->dimension(1) - cols_out_of_bounds[1], 1)); |
| 218 | |
| 219 | int rows_in_bounds = static_cast<int32_t>(_crop_results[num_box].get()->info()->dimension(2)) - rows_out_of_bounds[0] - rows_out_of_bounds[1]; |
| 220 | if(rows_in_bounds > 0) |
| 221 | { |
| 222 | // Fill all elements that share a row with an in bounds element with the extrapolation value. |
| 223 | if(cols_out_of_bounds[0] > 0) |
| 224 | { |
| 225 | Window slice_fill_cols_before(slice_in); |
| 226 | slice_fill_cols_before.set(1, Window::Dimension(0, cols_out_of_bounds[0], 1)); |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 227 | auto kernel = std::make_unique<CLMemsetKernel>(); |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 228 | kernel->configure(compile_context, _crop_results[num_box].get(), extrapolation_value, &slice_fill_cols_before); |
| 229 | _internal_kernels.push_back(std::move(kernel)); |
| 230 | } |
| 231 | |
| 232 | if(cols_out_of_bounds[1] > 0) |
| 233 | { |
| 234 | Window slice_fill_cols_after(slice_in); |
| 235 | slice_fill_cols_after.set(1, Window::Dimension(_crop_results[num_box].get()->info()->dimension(1) - cols_out_of_bounds[1], _crop_results[num_box].get()->info()->dimension(1), 1)); |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 236 | auto kernel = std::make_unique<CLMemsetKernel>(); |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 237 | kernel->configure(compile_context, _crop_results[num_box].get(), extrapolation_value, &slice_fill_cols_after); |
| 238 | _internal_kernels.push_back(std::move(kernel)); |
| 239 | } |
| 240 | |
| 241 | // Copy all elements within the input bounds from the input tensor. |
| 242 | int cols_in_bounds = static_cast<int32_t>(_crop_results[num_box].get()->info()->dimension(1)) - cols_out_of_bounds[0] - cols_out_of_bounds[1]; |
| 243 | if(cols_in_bounds > 0) |
| 244 | { |
| 245 | Coordinates2D start_in{ is_width_flipped ? start[0] - cols_out_of_bounds[0] : start[0] + cols_out_of_bounds[0], |
| 246 | is_height_flipped ? start[1] - rows_out_of_bounds[0] : start[1] + rows_out_of_bounds[0] }; |
| 247 | Coordinates2D end_in{ is_width_flipped ? start_in.x - cols_in_bounds + 1 : start_in.x + cols_in_bounds - 1, |
| 248 | is_height_flipped ? start_in.y - rows_in_bounds + 1 : start_in.y + rows_in_bounds - 1 }; |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 249 | auto kernel = std::make_unique<CLCropKernel>(); |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 250 | |
| 251 | kernel->configure(compile_context, _input, _crop_results[num_box].get(), start_in, end_in, batch_index, extrapolation_value, &slice_in); |
| 252 | _internal_kernels.push_back(std::move(kernel)); |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | // Fill all rows after the in bounds elements with the extrapolation value. |
| 257 | if(rows_out_of_bounds[1] > 0) |
| 258 | { |
| 259 | Window slice_fill_rows_after(full_window); |
| 260 | slice_fill_rows_after.set(2, Window::Dimension(_crop_results[num_box].get()->info()->dimension(2) - rows_out_of_bounds[1], _crop_results[num_box].get()->info()->dimension(2), 1)); |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 261 | auto kernel = std::make_unique<CLMemsetKernel>(); |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 262 | kernel->configure(compile_context, _crop_results[num_box].get(), extrapolation_value, &slice_fill_rows_after); |
| 263 | _internal_kernels.push_back(std::move(kernel)); |
| 264 | } |
George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 265 | } |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 266 | _boxes->unmap(CLScheduler::get().queue()); |
| 267 | _box_ind->unmap(CLScheduler::get().queue()); |
| 268 | CLScheduler::get().sync(); |
George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 269 | } |
| 270 | |
| 271 | void CLCropResize::run() |
| 272 | { |
| 273 | ARM_COMPUTE_ERROR_ON_MSG(_output == nullptr, "Unconfigured function"); |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 274 | |
| 275 | for(unsigned int i = 0; i < _internal_kernels.size(); ++i) |
George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 276 | { |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 277 | CLScheduler::get().enqueue(*(_internal_kernels[i])); |
George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 278 | } |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 279 | |
George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 280 | CLScheduler::get().sync(); |
Michalis Spyrou | a4f378d | 2019-04-26 14:54:54 +0100 | [diff] [blame] | 281 | for(auto &kernel : _scale) |
George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 282 | { |
Michalis Spyrou | a4f378d | 2019-04-26 14:54:54 +0100 | [diff] [blame] | 283 | kernel->run(); |
George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 284 | } |
| 285 | CLScheduler::get().sync(); |
Michalis Spyrou | a4f378d | 2019-04-26 14:54:54 +0100 | [diff] [blame] | 286 | for(auto &kernel : _copy) |
George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 287 | { |
Michalis Spyrou | a4f378d | 2019-04-26 14:54:54 +0100 | [diff] [blame] | 288 | CLScheduler::get().enqueue(*kernel, true); |
George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 289 | } |
| 290 | CLScheduler::get().sync(); |
| 291 | } |
| 292 | } // namespace arm_compute |