blob: 821412b14959abef4a7e13cf5b4c8f0c9d9e018f [file] [log] [blame]
George Wort894066d2019-02-15 15:12:52 +00001/*
Sheri Zhang7e20e292021-02-02 11:49:34 +00002 * Copyright (c) 2019-2021 Arm Limited.
George Wort894066d2019-02-15 15:12:52 +00003 *
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 Bottini2b84be52020-04-08 10:15:51 +010024#include "arm_compute/runtime/CL/functions/CLCropResize.h"
George Wort894066d2019-02-15 15:12:52 +000025
26#include "arm_compute/core/CL/CLHelpers.h"
George Wort894066d2019-02-15 15:12:52 +000027#include "arm_compute/runtime/CL/CLScheduler.h"
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010028
29#include "src/common/utils/Log.h"
Sang-Hoon Parkbef7fa22020-10-21 15:58:54 +010030#include "src/core/CL/kernels/CLFillBorderKernel.h"
Sang-Hoon Park68dd25f2020-10-19 16:00:11 +010031#include "src/core/helpers/AutoConfiguration.h"
32#include "src/core/helpers/WindowHelpers.h"
33
George Wort894066d2019-02-15 15:12:52 +000034#include <cstddef>
35
36namespace arm_compute
37{
38namespace
39{
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010040inline void configure_crop(const ICLTensor *input,
41 ICLTensor *crop_boxes,
42 ICLTensor *box_ind,
43 ICLTensor *output,
44 uint32_t crop_box_ind,
45 Coordinates &start,
46 Coordinates &end,
47 uint32_t &batch_index)
George Wort894066d2019-02-15 15:12:52 +000048{
49 batch_index = *(reinterpret_cast<int32_t *>(box_ind->ptr_to_element(Coordinates(crop_box_ind))));
50
51 // _crop_box_ind is used to index crop_boxes and retrieve the appropriate crop box.
52 // The crop box is specified by normalized coordinates [y0, x0, y1, x1].
53 const float x0 = *reinterpret_cast<const float *>(crop_boxes->ptr_to_element(Coordinates(1, crop_box_ind)));
54 const float y0 = *reinterpret_cast<const float *>(crop_boxes->ptr_to_element(Coordinates(0, crop_box_ind)));
55 const float x1 = *reinterpret_cast<const float *>(crop_boxes->ptr_to_element(Coordinates(3, crop_box_ind)));
56 const float y1 = *reinterpret_cast<const float *>(crop_boxes->ptr_to_element(Coordinates(2, crop_box_ind)));
57 // The normalized coordinates are scaled to retrieve the floating point image coordinates which are rounded to integers.
58 start = Coordinates(std::floor(x0 * (input->info()->tensor_shape()[1] - 1) + 0.5f),
59 std::floor(y0 * (input->info()->tensor_shape()[2] - 1) + 0.5f));
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010060 end = Coordinates(std::floor(x1 * (input->info()->tensor_shape()[1] - 1) + 0.5f),
61 std::floor(y1 * (input->info()->tensor_shape()[2] - 1) + 0.5f));
62 const TensorShape out_shape(input->info()->tensor_shape()[0], static_cast<uint32_t>(abs(end[0] - start[0])) + 1,
63 static_cast<uint32_t>(abs(end[1] - start[1])) + 1);
George Wort894066d2019-02-15 15:12:52 +000064 output->info()->set_tensor_shape(out_shape);
65}
George Wort894066d2019-02-15 15:12:52 +000066} // namespace
67
68CLCropResize::CLCropResize()
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010069 : _input(nullptr),
70 _boxes(nullptr),
71 _box_ind(nullptr),
72 _output(nullptr),
73 _num_boxes(0),
74 _method(),
75 _extrapolation_value(0),
76 _scale(),
77 _copy(),
78 _crop_results(),
79 _scaled_results(),
80 _internal_functions()
George Wort894066d2019-02-15 15:12:52 +000081{
82}
83
Sang-Hoon Parkbef7fa22020-10-21 15:58:54 +010084CLCropResize::~CLCropResize() = default;
85
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010086Status CLCropResize::validate(const ITensorInfo *input,
87 ITensorInfo *boxes,
88 ITensorInfo *box_ind,
89 const ITensorInfo *output,
90 Coordinates2D crop_size,
91 InterpolationPolicy method,
92 float extrapolation_value)
George Wort894066d2019-02-15 15:12:52 +000093{
94 ARM_COMPUTE_RETURN_ERROR_ON(crop_size.x <= 0 || crop_size.y <= 0);
95 ARM_COMPUTE_RETURN_ERROR_ON(method == InterpolationPolicy::AREA);
96 ARM_COMPUTE_RETURN_ERROR_ON(boxes->tensor_shape()[0] != 4);
97 ARM_COMPUTE_RETURN_ERROR_ON(boxes->tensor_shape()[1] != box_ind->tensor_shape()[0]);
98 TensorInfo temp_info;
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010099 ARM_COMPUTE_RETURN_ON_ERROR(CLCrop::validate(input->clone().get(), &temp_info, {0, 0}, {1, 1},
100 input->dimension(3) - 1, extrapolation_value));
101 if (output->total_size() > 0)
George Wort894066d2019-02-15 15:12:52 +0000102 {
103 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_NOT_IN(output, DataType::F32);
104 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_LAYOUT(input, output);
105 TensorShape out_shape(input->tensor_shape()[0], crop_size.x, crop_size.y, boxes->tensor_shape()[1]);
106 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(output->tensor_shape(), out_shape);
107 }
108 return Status{};
109}
110
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100111void CLCropResize::configure(const ICLTensor *input,
112 ICLTensor *boxes,
113 ICLTensor *box_ind,
114 ICLTensor *output,
115 Coordinates2D crop_size,
116 InterpolationPolicy method,
117 float extrapolation_value)
George Wort894066d2019-02-15 15:12:52 +0000118{
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100119 configure(CLKernelLibrary::get().get_compile_context(), input, boxes, box_ind, output, crop_size, method,
120 extrapolation_value);
Manuel Bottini2b84be52020-04-08 10:15:51 +0100121}
122
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100123void CLCropResize::configure(const CLCompileContext &compile_context,
124 const ICLTensor *input,
125 ICLTensor *boxes,
126 ICLTensor *box_ind,
127 ICLTensor *output,
128 Coordinates2D crop_size,
129 InterpolationPolicy method,
130 float extrapolation_value)
Manuel Bottini2b84be52020-04-08 10:15:51 +0100131{
132 ARM_COMPUTE_ERROR_ON_NULLPTR(input, output, boxes, box_ind);
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100133 ARM_COMPUTE_ERROR_THROW_ON(CLCropResize::validate(input->info(), boxes->info(), box_ind->info(), output->info(),
134 crop_size, method, extrapolation_value));
ramelg016d891572021-09-29 10:05:09 +0100135 ARM_COMPUTE_LOG_PARAMS(input, boxes, box_ind, output, crop_size, method, extrapolation_value);
George Wort894066d2019-02-15 15:12:52 +0000136
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100137 TensorShape output_shape =
138 TensorShape(input->info()->tensor_shape()[0], crop_size.x, crop_size.y, boxes->info()->tensor_shape()[1]);
Manuel Bottini2b84be52020-04-08 10:15:51 +0100139 auto_init_if_empty(*output->info(), output_shape, 1, DataType::F32);
140
George Wort894066d2019-02-15 15:12:52 +0000141 _num_boxes = boxes->info()->tensor_shape()[1];
142 TensorShape out_shape(input->info()->tensor_shape()[0], crop_size.x, crop_size.y);
143
144 _input = input;
145 _boxes = boxes;
146 _box_ind = box_ind;
147 _output = output;
148 _method = method;
149 _extrapolation_value = extrapolation_value;
150
151 // For each crop box:
152 // - The initial cropped image is produced as specified by boxes[i] from the 3D image input[box_ind[i]].
Sheri Zhang7e20e292021-02-02 11:49:34 +0000153 // Possibly using a CLCrop and up to four CLFills.
George Wort894066d2019-02-15 15:12:52 +0000154 // - A tensor is required to hold this initial cropped image.
155 // - A scale function is used to resize the cropped image to the size specified by crop_size.
156 // - A tensor is required to hold the final scaled image before it is copied into the 4D output
Sheri Zhang7e20e292021-02-02 11:49:34 +0000157 // that will hold all final cropped and scaled 3D images using CLCopy.
Manuel Bottini2b84be52020-04-08 10:15:51 +0100158
159 // The contents of _boxes and _box_ind are required to calculate the shape
160 // of the initial cropped image and thus are required to configure the
161 // kernels used for cropping and scaling.
162 _boxes->map(CLScheduler::get().queue());
163 _box_ind->map(CLScheduler::get().queue());
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100164 for (unsigned int num_box = 0; num_box < _num_boxes; ++num_box)
George Wort894066d2019-02-15 15:12:52 +0000165 {
Georgios Pinitas40f51a62020-11-21 03:04:18 +0000166 auto crop_tensor = std::make_unique<CLTensor>();
George Wort894066d2019-02-15 15:12:52 +0000167 TensorInfo crop_result_info(1, DataType::F32);
168 crop_result_info.set_data_layout(DataLayout::NHWC);
Michalis Spyroua4f378d2019-04-26 14:54:54 +0100169 crop_tensor->allocator()->init(crop_result_info);
170 _crop_results.emplace_back(std::move(crop_tensor));
George Wort894066d2019-02-15 15:12:52 +0000171
Georgios Pinitas40f51a62020-11-21 03:04:18 +0000172 auto scale_tensor = std::make_unique<CLTensor>();
George Wort894066d2019-02-15 15:12:52 +0000173 TensorInfo scaled_result_info(out_shape, 1, DataType::F32);
174 scaled_result_info.set_data_layout(DataLayout::NHWC);
Michalis Spyroua4f378d2019-04-26 14:54:54 +0100175 scale_tensor->allocator()->init(scaled_result_info);
176 _scaled_results.emplace_back(std::move(scale_tensor));
Manuel Bottini2b84be52020-04-08 10:15:51 +0100177
178 // Size of the crop box in _boxes has to be given before the configure
179 uint32_t batch_index;
180 Coordinates start{};
181 Coordinates end{};
182 configure_crop(_input, _boxes, _box_ind, _crop_results[num_box].get(), num_box, start, end, batch_index);
183
Georgios Pinitas40f51a62020-11-21 03:04:18 +0000184 auto scale_kernel = std::make_unique<CLScale>();
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100185 scale_kernel->configure(
186 compile_context, _crop_results[num_box].get(), _scaled_results[num_box].get(),
187 ScaleKernelInfo{_method, BorderMode::CONSTANT, PixelValue(_extrapolation_value), SamplingPolicy::TOP_LEFT});
Manuel Bottini2b84be52020-04-08 10:15:51 +0100188 _scale.emplace_back(std::move(scale_kernel));
189
190 Window win = calculate_max_window(*_output->info());
191 win.set(3, Window::Dimension(num_box, num_box + 1, 1));
192
Sheri Zhang7e20e292021-02-02 11:49:34 +0000193 auto copy_kernel = std::make_unique<CLCopy>();
SiCong Li3580c752020-10-14 17:00:56 +0100194 copy_kernel->configure(compile_context, _scaled_results[num_box].get(), _output, &win);
Manuel Bottini2b84be52020-04-08 10:15:51 +0100195 _copy.emplace_back(std::move(copy_kernel));
196
197 _crop_results[num_box]->allocator()->allocate();
198 _scaled_results[num_box]->allocator()->allocate();
199
200 bool is_width_flipped = end[0] < start[0];
201 bool is_height_flipped = end[1] < start[1];
202 /** The number of rows out of bounds at the start and end of _crop_results[num_box].get(). */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100203 std::array<int32_t, 2> rows_out_of_bounds{0};
Manuel Bottini2b84be52020-04-08 10:15:51 +0100204 /** The number of columns out of bounds at the start and end of _crop_results[num_box].get(). */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100205 std::array<int32_t, 2> cols_out_of_bounds{0};
206 if (is_height_flipped)
Manuel Bottini2b84be52020-04-08 10:15:51 +0100207 {
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100208 rows_out_of_bounds[0] = start[1] >= static_cast<int32_t>(_input->info()->dimension(2))
209 ? std::min(start[1] - _input->info()->dimension(2) + 1,
210 _crop_results[num_box].get()->info()->dimension(2))
211 : 0;
212 rows_out_of_bounds[1] =
213 end[1] < 0 ? std::min(-end[1], static_cast<int32_t>(_crop_results[num_box].get()->info()->dimension(2)))
214 : 0;
Manuel Bottini2b84be52020-04-08 10:15:51 +0100215 }
216 else
217 {
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100218 rows_out_of_bounds[0] =
219 start[1] < 0
220 ? std::min(-start[1], static_cast<int32_t>(_crop_results[num_box].get()->info()->dimension(2)))
221 : 0;
222 rows_out_of_bounds[1] = end[1] >= static_cast<int32_t>(_input->info()->dimension(2))
223 ? std::min(end[1] - _input->info()->dimension(2) + 1,
224 _crop_results[num_box].get()->info()->dimension(2))
225 : 0;
Manuel Bottini2b84be52020-04-08 10:15:51 +0100226 }
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100227 if (is_width_flipped)
Manuel Bottini2b84be52020-04-08 10:15:51 +0100228 {
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100229 cols_out_of_bounds[0] = start[0] >= static_cast<int32_t>(_input->info()->dimension(1))
230 ? std::min(start[0] - _input->info()->dimension(1) + 1,
231 _crop_results[num_box].get()->info()->dimension(1))
232 : 0;
233 cols_out_of_bounds[1] =
234 end[0] < 0 ? std::min(-end[0], static_cast<int32_t>(_crop_results[num_box].get()->info()->dimension(1)))
235 : 0;
Manuel Bottini2b84be52020-04-08 10:15:51 +0100236 }
237 else
238 {
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100239 cols_out_of_bounds[0] =
240 start[0] < 0
241 ? std::min(-start[0], static_cast<int32_t>(_crop_results[num_box].get()->info()->dimension(1)))
242 : 0;
243 cols_out_of_bounds[1] = end[0] >= static_cast<int32_t>(_input->info()->dimension(1))
244 ? std::min(end[0] - _input->info()->dimension(1) + 1,
245 _crop_results[num_box].get()->info()->dimension(1))
246 : 0;
Manuel Bottini2b84be52020-04-08 10:15:51 +0100247 }
248
249 Window full_window = calculate_max_window(*_crop_results[num_box].get()->info());
250
251 // Full _crop_results[num_box].get() window:
252 // --------------------------------
253 // | Out of bounds |
254 // | rows before |
255 // |------------------------------|
256 // | Out of | In | Out of |
257 // | bounds | bounds | bounds |
258 // | cols | elements | cols |
259 // | before | copied | after |
260 // | | from input | |
261 // |------------------------------|
262 // | Out of bounds |
263 // | rows after |
264 // |------------------------------|
265 // Use a separate _crop_results[num_box].get() window for each section of the full _crop_results[num_box].get() window.
266 // Fill all _crop_results[num_box].get() rows that have no elements that are within the input bounds
267 // with the extrapolation value using memset.
268 // First for the rows before the in bounds rows.
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100269 if (rows_out_of_bounds[0] > 0)
Manuel Bottini2b84be52020-04-08 10:15:51 +0100270 {
271 Window slice_fill_rows_before(full_window);
272 slice_fill_rows_before.set(2, Window::Dimension(0, rows_out_of_bounds[0], 1));
Sheri Zhang7e20e292021-02-02 11:49:34 +0000273 auto kernel = std::make_unique<CLFill>();
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100274 kernel->configure(compile_context, _crop_results[num_box].get(), extrapolation_value,
275 &slice_fill_rows_before);
Sheri Zhang7e20e292021-02-02 11:49:34 +0000276 //_internal_functions.emplace_back(std::move(kernel));
277 _internal_functions.push_back(std::move(kernel));
Manuel Bottini2b84be52020-04-08 10:15:51 +0100278 }
279
280 Window slice_in(full_window);
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100281 slice_in.set(2,
282 Window::Dimension(rows_out_of_bounds[0],
283 _crop_results[num_box].get()->info()->dimension(2) - rows_out_of_bounds[1], 1));
284 slice_in.set(1,
285 Window::Dimension(cols_out_of_bounds[0],
286 _crop_results[num_box].get()->info()->dimension(1) - cols_out_of_bounds[1], 1));
Manuel Bottini2b84be52020-04-08 10:15:51 +0100287
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100288 int rows_in_bounds = static_cast<int32_t>(_crop_results[num_box].get()->info()->dimension(2)) -
289 rows_out_of_bounds[0] - rows_out_of_bounds[1];
290 if (rows_in_bounds > 0)
Manuel Bottini2b84be52020-04-08 10:15:51 +0100291 {
292 // Fill all elements that share a row with an in bounds element with the extrapolation value.
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100293 if (cols_out_of_bounds[0] > 0)
Manuel Bottini2b84be52020-04-08 10:15:51 +0100294 {
295 Window slice_fill_cols_before(slice_in);
296 slice_fill_cols_before.set(1, Window::Dimension(0, cols_out_of_bounds[0], 1));
Sheri Zhang7e20e292021-02-02 11:49:34 +0000297 auto kernel = std::make_unique<CLFill>();
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100298 kernel->configure(compile_context, _crop_results[num_box].get(), extrapolation_value,
299 &slice_fill_cols_before);
Sheri Zhang7e20e292021-02-02 11:49:34 +0000300 //_internal_functions.emplace_back(std::move(kernel));
301 _internal_functions.push_back(std::move(kernel));
Manuel Bottini2b84be52020-04-08 10:15:51 +0100302 }
303
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100304 if (cols_out_of_bounds[1] > 0)
Manuel Bottini2b84be52020-04-08 10:15:51 +0100305 {
306 Window slice_fill_cols_after(slice_in);
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100307 slice_fill_cols_after.set(
308 1, Window::Dimension(_crop_results[num_box].get()->info()->dimension(1) - cols_out_of_bounds[1],
309 _crop_results[num_box].get()->info()->dimension(1), 1));
Sheri Zhang7e20e292021-02-02 11:49:34 +0000310 auto kernel = std::make_unique<CLFill>();
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100311 kernel->configure(compile_context, _crop_results[num_box].get(), extrapolation_value,
312 &slice_fill_cols_after);
Sheri Zhang7e20e292021-02-02 11:49:34 +0000313 //_internal_functions.emplace_back(std::move(kernel));
314 _internal_functions.push_back(std::move(kernel));
Manuel Bottini2b84be52020-04-08 10:15:51 +0100315 }
316
317 // Copy all elements within the input bounds from the input tensor.
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100318 int cols_in_bounds = static_cast<int32_t>(_crop_results[num_box].get()->info()->dimension(1)) -
319 cols_out_of_bounds[0] - cols_out_of_bounds[1];
320 if (cols_in_bounds > 0)
Manuel Bottini2b84be52020-04-08 10:15:51 +0100321 {
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100322 Coordinates2D start_in{
323 is_width_flipped ? start[0] - cols_out_of_bounds[0] : start[0] + cols_out_of_bounds[0],
324 is_height_flipped ? start[1] - rows_out_of_bounds[0] : start[1] + rows_out_of_bounds[0]};
325 Coordinates2D end_in{
326 is_width_flipped ? start_in.x - cols_in_bounds + 1 : start_in.x + cols_in_bounds - 1,
327 is_height_flipped ? start_in.y - rows_in_bounds + 1 : start_in.y + rows_in_bounds - 1};
Sheri Zhang7e20e292021-02-02 11:49:34 +0000328 auto kernel = std::make_unique<CLCrop>();
Manuel Bottini2b84be52020-04-08 10:15:51 +0100329
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100330 kernel->configure(compile_context, _input, _crop_results[num_box].get(), start_in, end_in, batch_index,
331 extrapolation_value, &slice_in);
Sheri Zhang7e20e292021-02-02 11:49:34 +0000332 //_internal_functions.emplace_back(std::move(kernel));
333 _internal_functions.push_back(std::move(kernel));
Manuel Bottini2b84be52020-04-08 10:15:51 +0100334 }
335 }
336
337 // Fill all rows after the in bounds elements with the extrapolation value.
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100338 if (rows_out_of_bounds[1] > 0)
Manuel Bottini2b84be52020-04-08 10:15:51 +0100339 {
340 Window slice_fill_rows_after(full_window);
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100341 slice_fill_rows_after.set(
342 2, Window::Dimension(_crop_results[num_box].get()->info()->dimension(2) - rows_out_of_bounds[1],
343 _crop_results[num_box].get()->info()->dimension(2), 1));
Sheri Zhang7e20e292021-02-02 11:49:34 +0000344 auto kernel = std::make_unique<CLFill>();
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100345 kernel->configure(compile_context, _crop_results[num_box].get(), extrapolation_value,
346 &slice_fill_rows_after);
Sheri Zhang7e20e292021-02-02 11:49:34 +0000347 //_internal_functions.emplace_back(std::move(kernel));
348 _internal_functions.push_back(std::move(kernel));
Manuel Bottini2b84be52020-04-08 10:15:51 +0100349 }
George Wort894066d2019-02-15 15:12:52 +0000350 }
Manuel Bottini2b84be52020-04-08 10:15:51 +0100351 _boxes->unmap(CLScheduler::get().queue());
352 _box_ind->unmap(CLScheduler::get().queue());
353 CLScheduler::get().sync();
George Wort894066d2019-02-15 15:12:52 +0000354}
355
356void CLCropResize::run()
357{
358 ARM_COMPUTE_ERROR_ON_MSG(_output == nullptr, "Unconfigured function");
Manuel Bottini2b84be52020-04-08 10:15:51 +0100359
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100360 for (unsigned int i = 0; i < _internal_functions.size(); ++i)
George Wort894066d2019-02-15 15:12:52 +0000361 {
Sheri Zhang7e20e292021-02-02 11:49:34 +0000362 _internal_functions[i]->run();
George Wort894066d2019-02-15 15:12:52 +0000363 }
Manuel Bottini2b84be52020-04-08 10:15:51 +0100364
George Wort894066d2019-02-15 15:12:52 +0000365 CLScheduler::get().sync();
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100366 for (auto &kernel : _scale)
George Wort894066d2019-02-15 15:12:52 +0000367 {
Michalis Spyroua4f378d2019-04-26 14:54:54 +0100368 kernel->run();
George Wort894066d2019-02-15 15:12:52 +0000369 }
370 CLScheduler::get().sync();
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100371 for (auto &kernel : _copy)
George Wort894066d2019-02-15 15:12:52 +0000372 {
Sheri Zhang7e20e292021-02-02 11:49:34 +0000373 kernel->run();
George Wort894066d2019-02-15 15:12:52 +0000374 }
375 CLScheduler::get().sync();
376}
ramelg016d891572021-09-29 10:05:09 +0100377} // namespace arm_compute