blob: 5fef4f9744275fdce329cabfc0217e2436c0fe43 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Diego Lopez Recasff860cf2018-02-22 13:08:01 +00002 * Copyright (c) 2016-2018 ARM Limited.
Anthony Barbier6ff3b192017-09-04 18:44:23 +01003 *
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 */
24#include "arm_compute/core/NEON/kernels/NEScaleKernel.h"
25
26#include "arm_compute/core/AccessWindowStatic.h"
Georgios Pinitasc47ef202018-11-16 18:19:43 +000027#include "arm_compute/core/CPP/Validate.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010028#include "arm_compute/core/Coordinates.h"
29#include "arm_compute/core/Error.h"
30#include "arm_compute/core/Helpers.h"
31#include "arm_compute/core/ITensor.h"
Georgios Pinitas393fa4c2018-05-08 15:54:53 +010032#include "arm_compute/core/NEON/wrapper/wrapper.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010033#include "arm_compute/core/TensorInfo.h"
34#include "arm_compute/core/Validate.h"
35#include "arm_compute/core/Window.h"
Georgios Pinitas393fa4c2018-05-08 15:54:53 +010036#include "arm_compute/core/utils/misc/Utility.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010037
38#include <arm_neon.h>
39#include <cstddef>
40#include <cstdint>
41
Georgios Pinitas393fa4c2018-05-08 15:54:53 +010042namespace arm_compute
43{
44namespace
45{
Georgios Pinitas20b43132018-05-14 16:05:23 +010046Status validate_arguments(const ITensorInfo *input, const ITensorInfo *dx, const ITensorInfo *dy,
47 const ITensorInfo *offsets, ITensorInfo *output, InterpolationPolicy policy,
48 BorderMode border_mode, SamplingPolicy sampling_policy)
Georgios Pinitas393fa4c2018-05-08 15:54:53 +010049{
Georgios Pinitasc47ef202018-11-16 18:19:43 +000050 ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(input);
51 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8, DataType::S16, DataType::F16, DataType::F32);
Georgios Pinitas20b43132018-05-14 16:05:23 +010052 ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(output);
53 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, output);
54 ARM_COMPUTE_RETURN_ERROR_ON(output == input);
55 ARM_COMPUTE_RETURN_ERROR_ON(sampling_policy != SamplingPolicy::CENTER);
56 ARM_COMPUTE_UNUSED(border_mode);
57
58 const DataLayout data_layout = input->data_layout();
59 ARM_COMPUTE_RETURN_ERROR_ON(output->dimension(get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH)) == 0);
60 ARM_COMPUTE_RETURN_ERROR_ON(output->dimension(get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT)) == 0);
61
62 if(policy == InterpolationPolicy::NEAREST_NEIGHBOR)
63 {
64 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(offsets, 1, DataType::S32);
65 }
66
67 if(policy == InterpolationPolicy::BILINEAR)
68 {
69 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(offsets, 1, DataType::S32);
70 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(dx, 1, DataType::F32);
71 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(dy, 1, DataType::F32);
72 }
73
74 if(policy == InterpolationPolicy::AREA)
75 {
76 ARM_COMPUTE_RETURN_ERROR_ON(data_layout != DataLayout::NCHW);
77 }
78
79 return Status{};
80}
81
82std::pair<Status, Window> validate_and_configure_window_nchw(ITensorInfo *input, ITensorInfo *dx, ITensorInfo *dy, ITensorInfo *offsets, ITensorInfo *output,
83 InterpolationPolicy policy, bool border_undefined, SamplingPolicy sampling_policy, BorderSize border_size)
84{
85 bool window_changed{ false };
86 Window win{};
87
Georgios Pinitas393fa4c2018-05-08 15:54:53 +010088 constexpr unsigned int num_elems_processed_per_iteration = 16;
89
90 // Configure kernel window
Georgios Pinitas20b43132018-05-14 16:05:23 +010091 win = calculate_max_window(*output, Steps(num_elems_processed_per_iteration));
Georgios Pinitas393fa4c2018-05-08 15:54:53 +010092
Georgios Pinitas20b43132018-05-14 16:05:23 +010093 const ValidRegion &input_valid_region = input->valid_region();
94
95 if(offsets != nullptr)
96 {
97 AccessWindowHorizontal offsets_access(offsets, 0, num_elems_processed_per_iteration);
98 window_changed = window_changed || update_window_and_padding(win, offsets_access);
99 }
100 if(dx != nullptr && dy != nullptr)
101 {
102 AccessWindowHorizontal dx_access(dx, 0, num_elems_processed_per_iteration);
103 AccessWindowHorizontal dy_access(dy, 0, num_elems_processed_per_iteration);
104 window_changed = window_changed || update_window_and_padding(win, dx_access, dy_access);
105 }
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100106
107 // Reads can occur within the valid region of the input
Georgios Pinitas20b43132018-05-14 16:05:23 +0100108 AccessWindowStatic input_access(input, input_valid_region.anchor[0] - border_size.left,
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100109 input_valid_region.anchor[1] - border_size.top,
110 input_valid_region.anchor[0] + input_valid_region.shape[0] + border_size.right,
111 input_valid_region.anchor[1] + input_valid_region.shape[1] + border_size.bottom);
Georgios Pinitas20b43132018-05-14 16:05:23 +0100112 AccessWindowHorizontal output_access(output, 0, num_elems_processed_per_iteration);
113 window_changed = window_changed || update_window_and_padding(win, input_access, output_access);
114 output_access.set_valid_region(win, calculate_valid_region_scale(*input, output->tensor_shape(),
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100115 policy, sampling_policy, border_undefined));
116
Georgios Pinitas20b43132018-05-14 16:05:23 +0100117 Status err = (window_changed) ? ARM_COMPUTE_CREATE_ERROR(ErrorCode::RUNTIME_ERROR, "Insufficient Padding!") : Status{};
118 return std::make_pair(err, win);
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100119}
Georgios Pinitas20b43132018-05-14 16:05:23 +0100120
121std::pair<Status, Window> validate_and_configure_window_nhwc(ITensorInfo *input, ITensorInfo *output,
122 InterpolationPolicy policy, bool border_undefined,
123 SamplingPolicy sampling_policy, BorderSize border_size)
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100124{
Georgios Pinitas20b43132018-05-14 16:05:23 +0100125 bool window_changed{ false };
126 Window win{};
127
128 const unsigned int num_elems_processed_per_iteration = (policy == InterpolationPolicy::NEAREST_NEIGHBOR) ? 16 / input->element_size() : 1;
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100129
130 // Configure kernel window
Georgios Pinitas20b43132018-05-14 16:05:23 +0100131 win = calculate_max_window(*output, Steps(num_elems_processed_per_iteration));
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100132
Georgios Pinitas20b43132018-05-14 16:05:23 +0100133 AccessWindowStatic input_access(input, 0, -border_size.top,
134 ceil_to_multiple(input->tensor_shape()[0], num_elems_processed_per_iteration),
135 input->tensor_shape()[1]);
136 AccessWindowHorizontal output_access(output, 0, num_elems_processed_per_iteration);
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100137
Georgios Pinitas20b43132018-05-14 16:05:23 +0100138 window_changed = update_window_and_padding(win, input_access, output_access);
139 output->set_valid_region(calculate_valid_region_scale(*input, output->tensor_shape(),
140 policy, sampling_policy, border_undefined));
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100141
Georgios Pinitas20b43132018-05-14 16:05:23 +0100142 Status err = (window_changed) ? ARM_COMPUTE_CREATE_ERROR(ErrorCode::RUNTIME_ERROR, "Insufficient Padding!") : Status{};
143 return std::make_pair(err, win);
144}
145
146std::pair<Status, Window> validate_and_configure_window(ITensorInfo *input, ITensorInfo *dx, ITensorInfo *dy, ITensorInfo *offsets, ITensorInfo *output,
147 InterpolationPolicy policy, bool border_undefined, SamplingPolicy sampling_policy, BorderSize border_size)
148{
149 std::pair<Status, Window> win_config;
150 switch(input->data_layout())
151 {
152 case DataLayout::NCHW:
153 win_config = validate_and_configure_window_nchw(input, dx, dy, offsets, output, policy, border_undefined, sampling_policy, border_size);
154 break;
155 case DataLayout::NHWC:
156 win_config = validate_and_configure_window_nhwc(input, output, policy, border_undefined, sampling_policy, border_size);
157 break;
158 default:
159 win_config = std::make_pair(ARM_COMPUTE_CREATE_ERROR(ErrorCode::RUNTIME_ERROR, "Unsupported data layout!"), Window{});
160 }
161
162 return win_config;
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100163}
164
165template <typename T>
166inline void scale_nearest_nhwc_core(const ITensor *input, const ITensor *offsets, ITensor *output,
167 float hr, Window window, const Window &win_in, size_t stride_w, size_t stride_h, size_t stride_c)
168{
169 Iterator in(input, win_in);
170 Iterator out(output, window);
171
172 const size_t offsets_stride = stride_w / sizeof(T);
173
174 execute_window_loop(window, [&](const Coordinates & id)
175 {
176 const auto offset = *reinterpret_cast<const int32_t *>(offsets->ptr_to_element(Coordinates(id.y(), id.z())));
177 const int in_yi = (id.z() + 0.5f) * hr;
178 const int offset_row = in_yi * stride_h + id.x() * stride_c;
179 wrapper::vstore(reinterpret_cast<T *>(out.ptr()),
180 wrapper::vloadq(reinterpret_cast<const T *>(in.ptr() + offset * offsets_stride + offset_row)));
181 },
182 in, out);
183}
184
185template <typename T>
186inline void scale_bilinear_nhwc_core(const ITensor *input, const ITensor *offsets, const ITensor *dx, const ITensor *dy, ITensor *output,
187 float hr, Window window, const Window &win_in, size_t stride_w, size_t stride_h, size_t stride_c, BorderMode border_mode)
188{
189 Iterator in(input, win_in);
190 Iterator out(output, window);
191
192 const size_t stride_w_elems = stride_w / sizeof(T);
193 const size_t stride_h_elems = stride_h / sizeof(T);
194
Georgios Pinitasfa7ad562018-05-15 17:38:40 +0100195 const int input_width = input->info()->dimension(1);
196 const int input_height = input->info()->dimension(2);
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100197
198 const T *border_area = reinterpret_cast<T *>(input->buffer() + input->info()->offset_first_element_in_bytes() - stride_w);
199
200 auto is_valid = [](int x, int low_x, int high_x, int y, int low_y, int high_y)
201 {
202 return !(x < low_x || x > high_x || y < low_y || y > high_y);
203 };
204
Georgios Pinitasfa7ad562018-05-15 17:38:40 +0100205 int border_size = (border_mode == BorderMode::UNDEFINED) ? 0 : 1;
206
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100207 execute_window_loop(window, [&](const Coordinates & id)
208 {
Georgios Pinitasfa7ad562018-05-15 17:38:40 +0100209 const auto offset = (*reinterpret_cast<const int32_t *>(offsets->ptr_to_element(Coordinates(id.y(), id.z())))) / static_cast<int>(sizeof(T));
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100210 const auto dx_scale = *reinterpret_cast<const float *>(dx->ptr_to_element(Coordinates(id.y(), id.z())));
211 const auto dy_scale = *reinterpret_cast<const float *>(dy->ptr_to_element(Coordinates(id.y(), id.z())));
212 const int in_yi = std::floor((id.z() + 0.5f) * hr - 0.5f);
213 const int offset_row = in_yi * stride_h + id.x() * stride_c;
214 const T *in_ptr = reinterpret_cast<T *>(in.ptr() + offset * stride_w + offset_row);
215
Georgios Pinitasfa7ad562018-05-15 17:38:40 +0100216 if(is_valid(offset, -border_size, input_width - 1 + border_size, in_yi, -border_size, input_height - 1 + border_size))
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100217 {
Georgios Pinitasfa7ad562018-05-15 17:38:40 +0100218 T a00 = 0, a01 = 0, a10 = 0, a11 = 0;
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100219
Georgios Pinitasfa7ad562018-05-15 17:38:40 +0100220 if(border_mode == BorderMode::CONSTANT)
221 {
222 a00 = is_valid(offset, 0, input_width - 1, in_yi, 0, input_height - 1) ? *in_ptr : *border_area;
223 a01 = is_valid(offset + 1, 0, input_width - 1, in_yi, 0, input_height - 1) ? *(in_ptr + stride_w_elems) : *border_area;
224 a10 = is_valid(offset, 0, input_width - 1, in_yi + 1, 0, input_height - 1) ? *(in_ptr + stride_h_elems) : *border_area;
225 a11 = is_valid(offset + 1, 0, input_width - 1, in_yi + 1, 0, input_height - 1) ? *(in_ptr + stride_h_elems + stride_w_elems) : *border_area;
226 }
227 else if(border_mode == BorderMode::REPLICATE)
228 {
229 auto clamped_x = utility::clamp<int>(offset, 0, input_width - 1);
230 auto clamped_x1 = utility::clamp<int>(offset + 1, 0, input_width - 1);
231 auto clamped_y = utility::clamp<int>(in_yi, 0, input_height - 1);
232 auto clamped_y1 = utility::clamp<int>(in_yi + 1, 0, input_height - 1);
233
234 a00 = *reinterpret_cast<T *>(in.ptr() + clamped_x * stride_w + clamped_y * stride_h + id.x() * stride_c);
235 a01 = *reinterpret_cast<T *>(in.ptr() + clamped_x1 * stride_w + clamped_y * stride_h + id.x() * stride_c);
236 a10 = *reinterpret_cast<T *>(in.ptr() + clamped_x * stride_w + clamped_y1 * stride_h + id.x() * stride_c);
237 a11 = *reinterpret_cast<T *>(in.ptr() + clamped_x1 * stride_w + clamped_y1 * stride_h + id.x() * stride_c);
238 }
239 else
240 {
241 a00 = is_valid(offset, 0, input_width - 1, in_yi, 0, input_height - 1) ? *in_ptr : 0;
242 a01 = is_valid(offset + 1, 0, input_width - 1, in_yi, 0, input_height - 1) ? *(in_ptr + stride_w_elems) : 0;
243 a10 = is_valid(offset, 0, input_width - 1, in_yi + 1, 0, input_height - 1) ? *(in_ptr + stride_h_elems) : 0;
244 a11 = is_valid(offset + 1, 0, input_width - 1, in_yi + 1, 0, input_height - 1) ? *(in_ptr + stride_h_elems + stride_w_elems) : 0;
245 }
246
247 // Perform interpolation
248 const float dx1 = 1.0f - dx_scale;
249 const float dy1 = 1.0f - dy_scale;
250
251 const float w1 = dx1 * dy1;
252 const float w2 = dx_scale * dy1;
253 const float w3 = dx1 * dy_scale;
254 const float w4 = dx_scale * dy_scale;
255
256 // Store result
257 *reinterpret_cast<T *>(out.ptr()) = static_cast<T>(a00 * w1 + a01 * w2 + a10 * w3 + a11 * w4);
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100258 }
259 else
260 {
Georgios Pinitasfa7ad562018-05-15 17:38:40 +0100261 if(border_mode == BorderMode::CONSTANT)
262 {
263 *reinterpret_cast<T *>(out.ptr()) = *border_area;
264 }
265 else if(border_mode == BorderMode::REPLICATE)
266 {
267 auto clamped_x = utility::clamp<int>(offset, 0, input_width - 1);
268 auto clamped_y = utility::clamp<int>(in_yi, 0, input_height - 1);
269 *reinterpret_cast<T *>(out.ptr()) = *reinterpret_cast<T *>(in.ptr() + clamped_x * stride_w + clamped_y * stride_h + id.x() * stride_c);
270 }
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100271 }
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100272 },
273 in, out);
274}
275} // namespace
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100276
277NEScaleKernel::NEScaleKernel()
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100278 : _func(nullptr), _offsets(nullptr), _dx(nullptr), _dy(nullptr), _input(nullptr), _output(nullptr), _policy(), _border_size(1), _border_mode()
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100279{
280}
281
282BorderSize NEScaleKernel::border_size() const
283{
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100284 return _border_size;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100285}
286
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100287void NEScaleKernel::configure(const ITensor *input, const ITensor *dx, const ITensor *dy, const ITensor *offsets,
288 ITensor *output, InterpolationPolicy policy, BorderMode border_mode, SamplingPolicy sampling_policy)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100289{
Georgios Pinitas20b43132018-05-14 16:05:23 +0100290 ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100291
Georgios Pinitas20b43132018-05-14 16:05:23 +0100292 // Perform validation step
293 ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(),
294 dx != nullptr ? dx->info() : nullptr,
295 dy != nullptr ? dy->info() : nullptr,
296 offsets != nullptr ? offsets->info() : nullptr,
297 output->info(),
298 policy, border_mode, sampling_policy));
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100299
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100300 // Get data layout and width/height indices
301 const DataLayout data_layout = input->info()->data_layout();
302 const int idx_width = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
303 const int idx_height = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100304
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100305 _input = input;
306 _output = output;
307 _offsets = offsets;
308 _dx = dx;
309 _dy = dy;
310 _policy = policy;
311 _border_size = BorderSize(1);
312 _border_mode = border_mode;
313
314 // Compute the ratio between source width/height and destination width/height
315 const auto wr = static_cast<float>(input->info()->dimension(idx_width)) / static_cast<float>(output->info()->dimension(idx_width));
316 const auto hr = static_cast<float>(input->info()->dimension(idx_height)) / static_cast<float>(output->info()->dimension(idx_height));
317
318 // Add constant border only on top in case of NHWC layout
319 if(data_layout == DataLayout::NHWC)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100320 {
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100321 _border_size = (border_mode == BorderMode::CONSTANT && policy == InterpolationPolicy::BILINEAR) ? BorderSize(1, 0, 0, 0) : BorderSize(0);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100322 }
323
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100324 // Area interpolation behaves as Nearest Neighbour in case of up-sampling
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100325 if(policy == InterpolationPolicy::AREA && wr <= 1.f && hr <= 1.f)
326 {
327 policy = InterpolationPolicy::NEAREST_NEIGHBOR;
328 }
329
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100330 // Select interpolation function
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100331 switch(policy)
332 {
333 case InterpolationPolicy::NEAREST_NEIGHBOR:
334 {
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100335 _func = (data_layout == DataLayout::NCHW) ? &NEScaleKernel::scale_nearest_nchw : &NEScaleKernel::scale_nhwc;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100336 break;
337 }
338 case InterpolationPolicy::BILINEAR:
339 {
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100340 _func = (data_layout == DataLayout::NCHW) ? &NEScaleKernel::scale_bilinear_nchw : &NEScaleKernel::scale_nhwc;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100341 break;
342 }
343 case InterpolationPolicy::AREA:
344 {
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100345 _func = &NEScaleKernel::scale_area_nchw;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100346 break;
347 }
348 default:
349 ARM_COMPUTE_ERROR("Unsupported interpolation mode");
350 }
351
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100352 // Configure window
Georgios Pinitas20b43132018-05-14 16:05:23 +0100353 std::pair<Status, Window> win_config = validate_and_configure_window(input->info(),
354 dx != nullptr ? dx->info() : nullptr,
355 dy != nullptr ? dy->info() : nullptr,
356 offsets != nullptr ? offsets->info() : nullptr,
357 output->info(),
358 policy, border_mode == BorderMode::UNDEFINED, sampling_policy, border_size());
359 ARM_COMPUTE_ERROR_THROW_ON(win_config.first);
360 INEKernel::configure(win_config.second);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100361}
362
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100363void NEScaleKernel::scale_nearest_nchw(const Window &window)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100364{
365 const size_t input_stride = _input->info()->strides_in_bytes()[1];
366
367 // Compute the ratio between source height and destination height
368 const auto hr = static_cast<float>(_input->info()->dimension(1)) / static_cast<float>(_output->info()->dimension(1));
369
370 // Don't increment in X and Y direction for the input tensor
371 // A pointer to the start of this plane is needed as base for the precomputed offsets
372 Window win_in(window);
373 win_in.set(Window::DimX, Window::Dimension(0, 0, 0));
374 win_in.set(Window::DimY, Window::Dimension(0, 0, 0));
375
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100376 // Set offsets window
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100377 Window win_off;
378 win_off.set(Window::DimX, window[Window::DimX]);
379 win_off.set(Window::DimY, window[Window::DimY]);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100380 for(size_t d = Window::DimZ; d < _offsets->info()->num_dimensions(); ++d)
381 {
382 win_off.set(d, Window::Dimension(0, 0, 0));
383 }
384
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100385 // Create iterators
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100386 Iterator in(_input, win_in);
387 Iterator out(_output, window);
388 Iterator offsets(_offsets, win_off);
389
390 switch(_input->info()->data_type())
391 {
392 case DataType::U8:
393 {
394 uint8x16_t tmp = vdupq_n_u8(0);
395
396 execute_window_loop(window, [&](const Coordinates & id)
397 {
398 const auto offsets_ptr = reinterpret_cast<const int32_t *>(offsets.ptr());
399 const uint8_t *const in_ptr = in.ptr();
400
Pablo Tellof5f34bb2017-08-22 13:34:13 +0100401 const int in_yi = std::floor((id.y() + 0.5f) * hr);
402 const int in_yi_clamped = std::min(static_cast<int>(_input->info()->dimension(1)), std::max(in_yi, -1));
403 ARM_COMPUTE_ERROR_ON(in_yi_clamped < -1 || in_yi_clamped > static_cast<int>(_input->info()->dimension(1)));
404 const int offset_row = in_yi_clamped * input_stride;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100405
406 tmp = vsetq_lane_u8(in_ptr[offsets_ptr[0] + offset_row], tmp, 0);
407 tmp = vsetq_lane_u8(in_ptr[offsets_ptr[1] + offset_row], tmp, 1);
408 tmp = vsetq_lane_u8(in_ptr[offsets_ptr[2] + offset_row], tmp, 2);
409 tmp = vsetq_lane_u8(in_ptr[offsets_ptr[3] + offset_row], tmp, 3);
410 tmp = vsetq_lane_u8(in_ptr[offsets_ptr[4] + offset_row], tmp, 4);
411 tmp = vsetq_lane_u8(in_ptr[offsets_ptr[5] + offset_row], tmp, 5);
412 tmp = vsetq_lane_u8(in_ptr[offsets_ptr[6] + offset_row], tmp, 6);
413 tmp = vsetq_lane_u8(in_ptr[offsets_ptr[7] + offset_row], tmp, 7);
414 tmp = vsetq_lane_u8(in_ptr[offsets_ptr[8] + offset_row], tmp, 8);
415 tmp = vsetq_lane_u8(in_ptr[offsets_ptr[9] + offset_row], tmp, 9);
416 tmp = vsetq_lane_u8(in_ptr[offsets_ptr[10] + offset_row], tmp, 10);
417 tmp = vsetq_lane_u8(in_ptr[offsets_ptr[11] + offset_row], tmp, 11);
418 tmp = vsetq_lane_u8(in_ptr[offsets_ptr[12] + offset_row], tmp, 12);
419 tmp = vsetq_lane_u8(in_ptr[offsets_ptr[13] + offset_row], tmp, 13);
420 tmp = vsetq_lane_u8(in_ptr[offsets_ptr[14] + offset_row], tmp, 14);
421 tmp = vsetq_lane_u8(in_ptr[offsets_ptr[15] + offset_row], tmp, 15);
422
423 vst1q_u8(out.ptr(), tmp);
424 },
425 in, offsets, out);
426 break;
427 }
428 case DataType::S16:
429 {
430 int16x8x2_t tmp =
431 {
432 {
433 vdupq_n_s16(0),
434 vdupq_n_s16(0)
435 }
436 };
437
438 execute_window_loop(window, [&](const Coordinates & id)
439 {
440 const auto offsets_ptr = reinterpret_cast<const int32_t *>(offsets.ptr());
441
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100442 const int in_yi = (id.y() + 0.5f) * hr;
443 const int offset_row = in_yi * input_stride;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100444
445 tmp.val[0] = vsetq_lane_s16(*reinterpret_cast<const int16_t *>(in.ptr() + offsets_ptr[0] + offset_row), tmp.val[0], 0);
446 tmp.val[0] = vsetq_lane_s16(*reinterpret_cast<const int16_t *>(in.ptr() + offsets_ptr[2] + offset_row), tmp.val[0], 1);
447 tmp.val[0] = vsetq_lane_s16(*reinterpret_cast<const int16_t *>(in.ptr() + offsets_ptr[4] + offset_row), tmp.val[0], 2);
448 tmp.val[0] = vsetq_lane_s16(*reinterpret_cast<const int16_t *>(in.ptr() + offsets_ptr[6] + offset_row), tmp.val[0], 3);
449 tmp.val[0] = vsetq_lane_s16(*reinterpret_cast<const int16_t *>(in.ptr() + offsets_ptr[8] + offset_row), tmp.val[0], 4);
450 tmp.val[0] = vsetq_lane_s16(*reinterpret_cast<const int16_t *>(in.ptr() + offsets_ptr[10] + offset_row), tmp.val[0], 5);
451 tmp.val[0] = vsetq_lane_s16(*reinterpret_cast<const int16_t *>(in.ptr() + offsets_ptr[12] + offset_row), tmp.val[0], 6);
452 tmp.val[0] = vsetq_lane_s16(*reinterpret_cast<const int16_t *>(in.ptr() + offsets_ptr[14] + offset_row), tmp.val[0], 7);
453
454 tmp.val[1] = vsetq_lane_s16(*reinterpret_cast<const int16_t *>(in.ptr() + offsets_ptr[1] + offset_row), tmp.val[1], 0);
455 tmp.val[1] = vsetq_lane_s16(*reinterpret_cast<const int16_t *>(in.ptr() + offsets_ptr[3] + offset_row), tmp.val[1], 1);
456 tmp.val[1] = vsetq_lane_s16(*reinterpret_cast<const int16_t *>(in.ptr() + offsets_ptr[5] + offset_row), tmp.val[1], 2);
457 tmp.val[1] = vsetq_lane_s16(*reinterpret_cast<const int16_t *>(in.ptr() + offsets_ptr[7] + offset_row), tmp.val[1], 3);
458 tmp.val[1] = vsetq_lane_s16(*reinterpret_cast<const int16_t *>(in.ptr() + offsets_ptr[9] + offset_row), tmp.val[1], 4);
459 tmp.val[1] = vsetq_lane_s16(*reinterpret_cast<const int16_t *>(in.ptr() + offsets_ptr[11] + offset_row), tmp.val[1], 5);
460 tmp.val[1] = vsetq_lane_s16(*reinterpret_cast<const int16_t *>(in.ptr() + offsets_ptr[13] + offset_row), tmp.val[1], 6);
461 tmp.val[1] = vsetq_lane_s16(*reinterpret_cast<const int16_t *>(in.ptr() + offsets_ptr[15] + offset_row), tmp.val[1], 7);
462
463 vst2q_s16(reinterpret_cast<int16_t *>(out.ptr()), tmp);
464 },
465 in, offsets, out);
466 break;
467 }
Georgios Pinitasc47ef202018-11-16 18:19:43 +0000468#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
469 case DataType::F16:
470 {
471 float16x8x2_t tmp =
472 {
473 {
474 vdupq_n_f16(0),
475 vdupq_n_f16(0)
476 }
477 };
478
479 execute_window_loop(window, [&](const Coordinates & id)
480 {
481 const auto offsets_ptr = reinterpret_cast<const int32_t *>(offsets.ptr());
482
483 const int in_yi = (id.y() + 0.5f) * hr;
484 const int offset_row = in_yi * input_stride;
485
486 tmp.val[0] = vsetq_lane_f16(*reinterpret_cast<const __fp16 *>(in.ptr() + offsets_ptr[0] + offset_row), tmp.val[0], 0);
487 tmp.val[0] = vsetq_lane_f16(*reinterpret_cast<const __fp16 *>(in.ptr() + offsets_ptr[2] + offset_row), tmp.val[0], 1);
488 tmp.val[0] = vsetq_lane_f16(*reinterpret_cast<const __fp16 *>(in.ptr() + offsets_ptr[4] + offset_row), tmp.val[0], 2);
489 tmp.val[0] = vsetq_lane_f16(*reinterpret_cast<const __fp16 *>(in.ptr() + offsets_ptr[6] + offset_row), tmp.val[0], 3);
490 tmp.val[0] = vsetq_lane_f16(*reinterpret_cast<const __fp16 *>(in.ptr() + offsets_ptr[8] + offset_row), tmp.val[0], 4);
491 tmp.val[0] = vsetq_lane_f16(*reinterpret_cast<const __fp16 *>(in.ptr() + offsets_ptr[10] + offset_row), tmp.val[0], 5);
492 tmp.val[0] = vsetq_lane_f16(*reinterpret_cast<const __fp16 *>(in.ptr() + offsets_ptr[12] + offset_row), tmp.val[0], 6);
493 tmp.val[0] = vsetq_lane_f16(*reinterpret_cast<const __fp16 *>(in.ptr() + offsets_ptr[14] + offset_row), tmp.val[0], 7);
494
495 tmp.val[1] = vsetq_lane_f16(*reinterpret_cast<const __fp16 *>(in.ptr() + offsets_ptr[1] + offset_row), tmp.val[1], 0);
496 tmp.val[1] = vsetq_lane_f16(*reinterpret_cast<const __fp16 *>(in.ptr() + offsets_ptr[3] + offset_row), tmp.val[1], 1);
497 tmp.val[1] = vsetq_lane_f16(*reinterpret_cast<const __fp16 *>(in.ptr() + offsets_ptr[5] + offset_row), tmp.val[1], 2);
498 tmp.val[1] = vsetq_lane_f16(*reinterpret_cast<const __fp16 *>(in.ptr() + offsets_ptr[7] + offset_row), tmp.val[1], 3);
499 tmp.val[1] = vsetq_lane_f16(*reinterpret_cast<const __fp16 *>(in.ptr() + offsets_ptr[9] + offset_row), tmp.val[1], 4);
500 tmp.val[1] = vsetq_lane_f16(*reinterpret_cast<const __fp16 *>(in.ptr() + offsets_ptr[11] + offset_row), tmp.val[1], 5);
501 tmp.val[1] = vsetq_lane_f16(*reinterpret_cast<const __fp16 *>(in.ptr() + offsets_ptr[13] + offset_row), tmp.val[1], 6);
502 tmp.val[1] = vsetq_lane_f16(*reinterpret_cast<const __fp16 *>(in.ptr() + offsets_ptr[15] + offset_row), tmp.val[1], 7);
503
504 vst2q_f16(reinterpret_cast<__fp16 *>(out.ptr()), tmp);
505 },
506 in, offsets, out);
507 break;
508 }
509#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
Georgios Pinitas583137c2017-08-31 18:12:42 +0100510 case DataType::F32:
511 {
512 float32x4x4_t tmp =
513 {
514 {
515 vdupq_n_f32(0),
516 vdupq_n_f32(0),
517 vdupq_n_f32(0),
518 vdupq_n_f32(0)
519 }
520 };
521
522 execute_window_loop(window, [&](const Coordinates & id)
523 {
524 const auto offsets_ptr = reinterpret_cast<const int32_t *>(offsets.ptr());
525
526 const int in_yi = (id.y() + 0.5f) * hr;
527 const int offset_row = in_yi * input_stride;
528
529 tmp.val[0] = vsetq_lane_f32(*reinterpret_cast<const float *>(in.ptr() + offsets_ptr[0] + offset_row), tmp.val[0], 0);
530 tmp.val[0] = vsetq_lane_f32(*reinterpret_cast<const float *>(in.ptr() + offsets_ptr[4] + offset_row), tmp.val[0], 1);
531 tmp.val[0] = vsetq_lane_f32(*reinterpret_cast<const float *>(in.ptr() + offsets_ptr[8] + offset_row), tmp.val[0], 2);
532 tmp.val[0] = vsetq_lane_f32(*reinterpret_cast<const float *>(in.ptr() + offsets_ptr[12] + offset_row), tmp.val[0], 3);
533
534 tmp.val[1] = vsetq_lane_f32(*reinterpret_cast<const float *>(in.ptr() + offsets_ptr[1] + offset_row), tmp.val[1], 0);
535 tmp.val[1] = vsetq_lane_f32(*reinterpret_cast<const float *>(in.ptr() + offsets_ptr[5] + offset_row), tmp.val[1], 1);
536 tmp.val[1] = vsetq_lane_f32(*reinterpret_cast<const float *>(in.ptr() + offsets_ptr[9] + offset_row), tmp.val[1], 2);
537 tmp.val[1] = vsetq_lane_f32(*reinterpret_cast<const float *>(in.ptr() + offsets_ptr[13] + offset_row), tmp.val[1], 3);
538
539 tmp.val[2] = vsetq_lane_f32(*reinterpret_cast<const float *>(in.ptr() + offsets_ptr[2] + offset_row), tmp.val[2], 0);
540 tmp.val[2] = vsetq_lane_f32(*reinterpret_cast<const float *>(in.ptr() + offsets_ptr[6] + offset_row), tmp.val[2], 1);
541 tmp.val[2] = vsetq_lane_f32(*reinterpret_cast<const float *>(in.ptr() + offsets_ptr[10] + offset_row), tmp.val[2], 2);
542 tmp.val[2] = vsetq_lane_f32(*reinterpret_cast<const float *>(in.ptr() + offsets_ptr[14] + offset_row), tmp.val[2], 3);
543
544 tmp.val[3] = vsetq_lane_f32(*reinterpret_cast<const float *>(in.ptr() + offsets_ptr[3] + offset_row), tmp.val[3], 0);
545 tmp.val[3] = vsetq_lane_f32(*reinterpret_cast<const float *>(in.ptr() + offsets_ptr[7] + offset_row), tmp.val[3], 1);
546 tmp.val[3] = vsetq_lane_f32(*reinterpret_cast<const float *>(in.ptr() + offsets_ptr[11] + offset_row), tmp.val[3], 2);
547 tmp.val[3] = vsetq_lane_f32(*reinterpret_cast<const float *>(in.ptr() + offsets_ptr[15] + offset_row), tmp.val[3], 3);
548
549 vst4q_f32(reinterpret_cast<float *>(out.ptr()), tmp);
550 },
551 in, offsets, out);
552 break;
553 }
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100554 default:
555 ARM_COMPUTE_ERROR("Not supported");
556 break;
557 }
558}
559
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100560void NEScaleKernel::scale_bilinear_nchw(const Window &window)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100561{
Georgios Pinitasc47ef202018-11-16 18:19:43 +0000562 ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(_input, 1, DataType::U8, DataType::S16, DataType::F16, DataType::F32);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100563
564 // Compute the ratio between source height and destination height
565 const auto hr = static_cast<float>(_input->info()->dimension(1)) / static_cast<float>(_output->info()->dimension(1));
566
567 // Don't increment in X and Y direction for the input tensor
568 // A pointer to the start of this plane is needed as base for the precomputed offsets
569 Window win_in(window);
570 win_in.set(Window::DimX, Window::Dimension(0, 0, 0));
571 win_in.set(Window::DimY, Window::Dimension(0, 0, 0));
572
573 Window win_off;
574 win_off.set(Window::DimX, window.x());
575 win_off.set(Window::DimY, window.y());
576
577 for(size_t d = Window::DimZ; d < _offsets->info()->num_dimensions(); ++d)
578 {
579 win_off.set(d, Window::Dimension(0, 0, 0));
580 }
581
582 Iterator in(_input, win_in);
583 Iterator out(_output, window);
584 Iterator offsets(_offsets, win_off);
585 Iterator dx(_dx, win_off);
586 Iterator dy(_dy, win_off);
587
588 /* Input image stride */
Georgios Pinitas583137c2017-08-31 18:12:42 +0100589 const size_t in_stide_in_bytes = _input->info()->strides_in_bytes()[1];
590 const size_t in_stride = in_stide_in_bytes / _input->info()->element_size();
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100591
Georgios Pinitas583137c2017-08-31 18:12:42 +0100592 switch(_input->info()->data_type())
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100593 {
Georgios Pinitas583137c2017-08-31 18:12:42 +0100594 case DataType::U8:
595 {
596 execute_window_loop(window, [&](const Coordinates & id)
597 {
598 const auto offsets_ptr = reinterpret_cast<const int32_t *>(offsets.ptr());
599 const auto dx_ptr = reinterpret_cast<const float *>(dx.ptr());
600 const auto dy_ptr = reinterpret_cast<const float *>(dy.ptr());
601 const auto in_ptr = reinterpret_cast<const uint8_t *>(in.ptr());
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100602
Georgios Pinitas583137c2017-08-31 18:12:42 +0100603 const int in_yi = std::floor((id.y() + 0.5f) * hr - 0.5f);
604 const int offset_row = in_yi * in_stide_in_bytes;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100605
Georgios Pinitas583137c2017-08-31 18:12:42 +0100606 uint8x8_t tmp0 = vdup_n_u8(0);
607 tmp0 = vset_lane_u8(delta_bilinear_c1(&in_ptr[offsets_ptr[0] + offset_row], in_stride, dx_ptr[0], dy_ptr[0]), tmp0, 0);
608 tmp0 = vset_lane_u8(delta_bilinear_c1(&in_ptr[offsets_ptr[1] + offset_row], in_stride, dx_ptr[1], dy_ptr[1]), tmp0, 1);
609 tmp0 = vset_lane_u8(delta_bilinear_c1(&in_ptr[offsets_ptr[2] + offset_row], in_stride, dx_ptr[2], dy_ptr[2]), tmp0, 2);
610 tmp0 = vset_lane_u8(delta_bilinear_c1(&in_ptr[offsets_ptr[3] + offset_row], in_stride, dx_ptr[3], dy_ptr[3]), tmp0, 3);
611 tmp0 = vset_lane_u8(delta_bilinear_c1(&in_ptr[offsets_ptr[4] + offset_row], in_stride, dx_ptr[4], dy_ptr[4]), tmp0, 4);
612 tmp0 = vset_lane_u8(delta_bilinear_c1(&in_ptr[offsets_ptr[5] + offset_row], in_stride, dx_ptr[5], dy_ptr[5]), tmp0, 5);
613 tmp0 = vset_lane_u8(delta_bilinear_c1(&in_ptr[offsets_ptr[6] + offset_row], in_stride, dx_ptr[6], dy_ptr[6]), tmp0, 6);
614 tmp0 = vset_lane_u8(delta_bilinear_c1(&in_ptr[offsets_ptr[7] + offset_row], in_stride, dx_ptr[7], dy_ptr[7]), tmp0, 7);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100615
Georgios Pinitas583137c2017-08-31 18:12:42 +0100616 uint8x8_t tmp1 = vdup_n_u8(0);
617 tmp1 = vset_lane_u8(delta_bilinear_c1(&in_ptr[offsets_ptr[8] + offset_row], in_stride, dx_ptr[8], dy_ptr[8]), tmp1, 0);
618 tmp1 = vset_lane_u8(delta_bilinear_c1(&in_ptr[offsets_ptr[9] + offset_row], in_stride, dx_ptr[9], dy_ptr[9]), tmp1, 1);
619 tmp1 = vset_lane_u8(delta_bilinear_c1(&in_ptr[offsets_ptr[10] + offset_row], in_stride, dx_ptr[10], dy_ptr[10]), tmp1, 2);
620 tmp1 = vset_lane_u8(delta_bilinear_c1(&in_ptr[offsets_ptr[11] + offset_row], in_stride, dx_ptr[11], dy_ptr[11]), tmp1, 3);
621 tmp1 = vset_lane_u8(delta_bilinear_c1(&in_ptr[offsets_ptr[12] + offset_row], in_stride, dx_ptr[12], dy_ptr[12]), tmp1, 4);
622 tmp1 = vset_lane_u8(delta_bilinear_c1(&in_ptr[offsets_ptr[13] + offset_row], in_stride, dx_ptr[13], dy_ptr[13]), tmp1, 5);
623 tmp1 = vset_lane_u8(delta_bilinear_c1(&in_ptr[offsets_ptr[14] + offset_row], in_stride, dx_ptr[14], dy_ptr[14]), tmp1, 6);
624 tmp1 = vset_lane_u8(delta_bilinear_c1(&in_ptr[offsets_ptr[15] + offset_row], in_stride, dx_ptr[15], dy_ptr[15]), tmp1, 7);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100625
Georgios Pinitas583137c2017-08-31 18:12:42 +0100626 vst1q_u8(out.ptr(), vcombine_u8(tmp0, tmp1));
627 },
628 in, offsets, dx, dy, out);
629 break;
630 }
631 case DataType::S16:
632 {
633 execute_window_loop(window, [&](const Coordinates & id)
634 {
635 const auto offsets_ptr = reinterpret_cast<const int32_t *>(offsets.ptr());
636 const auto dx_ptr = reinterpret_cast<const float *>(dx.ptr());
637 const auto dy_ptr = reinterpret_cast<const float *>(dy.ptr());
638
639 const int in_yi = std::floor((id.y() + 0.5f) * hr - 0.5f);
640 const int offset_row = in_yi * in_stide_in_bytes;
641
642 int16x8x2_t tmp =
643 {
644 {
645 vdupq_n_s16(0),
646 vdupq_n_s16(0)
647 }
648 };
649
650 tmp.val[0] = vsetq_lane_s16(delta_bilinear_c1(reinterpret_cast<const int16_t *>(in.ptr() + offsets_ptr[0] + offset_row), in_stride, dx_ptr[0], dy_ptr[0]), tmp.val[0], 0);
651 tmp.val[0] = vsetq_lane_s16(delta_bilinear_c1(reinterpret_cast<const int16_t *>(in.ptr() + offsets_ptr[2] + offset_row), in_stride, dx_ptr[2], dy_ptr[2]), tmp.val[0], 1);
652 tmp.val[0] = vsetq_lane_s16(delta_bilinear_c1(reinterpret_cast<const int16_t *>(in.ptr() + offsets_ptr[4] + offset_row), in_stride, dx_ptr[4], dy_ptr[4]), tmp.val[0], 2);
653 tmp.val[0] = vsetq_lane_s16(delta_bilinear_c1(reinterpret_cast<const int16_t *>(in.ptr() + offsets_ptr[6] + offset_row), in_stride, dx_ptr[6], dy_ptr[6]), tmp.val[0], 3);
654 tmp.val[0] = vsetq_lane_s16(delta_bilinear_c1(reinterpret_cast<const int16_t *>(in.ptr() + offsets_ptr[8] + offset_row), in_stride, dx_ptr[8], dy_ptr[8]), tmp.val[0], 4);
655 tmp.val[0] = vsetq_lane_s16(delta_bilinear_c1(reinterpret_cast<const int16_t *>(in.ptr() + offsets_ptr[10] + offset_row), in_stride, dx_ptr[10], dy_ptr[10]), tmp.val[0], 5);
656 tmp.val[0] = vsetq_lane_s16(delta_bilinear_c1(reinterpret_cast<const int16_t *>(in.ptr() + offsets_ptr[12] + offset_row), in_stride, dx_ptr[12], dy_ptr[12]), tmp.val[0], 6);
657 tmp.val[0] = vsetq_lane_s16(delta_bilinear_c1(reinterpret_cast<const int16_t *>(in.ptr() + offsets_ptr[14] + offset_row), in_stride, dx_ptr[14], dy_ptr[14]), tmp.val[0], 7);
658
659 tmp.val[1] = vsetq_lane_s16(delta_bilinear_c1(reinterpret_cast<const int16_t *>(in.ptr() + offsets_ptr[1] + offset_row), in_stride, dx_ptr[1], dy_ptr[1]), tmp.val[1], 0);
660 tmp.val[1] = vsetq_lane_s16(delta_bilinear_c1(reinterpret_cast<const int16_t *>(in.ptr() + offsets_ptr[3] + offset_row), in_stride, dx_ptr[3], dy_ptr[3]), tmp.val[1], 1);
661 tmp.val[1] = vsetq_lane_s16(delta_bilinear_c1(reinterpret_cast<const int16_t *>(in.ptr() + offsets_ptr[5] + offset_row), in_stride, dx_ptr[5], dy_ptr[5]), tmp.val[1], 2);
662 tmp.val[1] = vsetq_lane_s16(delta_bilinear_c1(reinterpret_cast<const int16_t *>(in.ptr() + offsets_ptr[7] + offset_row), in_stride, dx_ptr[7], dy_ptr[7]), tmp.val[1], 3);
663 tmp.val[1] = vsetq_lane_s16(delta_bilinear_c1(reinterpret_cast<const int16_t *>(in.ptr() + offsets_ptr[9] + offset_row), in_stride, dx_ptr[9], dy_ptr[9]), tmp.val[1], 4);
664 tmp.val[1] = vsetq_lane_s16(delta_bilinear_c1(reinterpret_cast<const int16_t *>(in.ptr() + offsets_ptr[11] + offset_row), in_stride, dx_ptr[11], dy_ptr[11]), tmp.val[1], 5);
665 tmp.val[1] = vsetq_lane_s16(delta_bilinear_c1(reinterpret_cast<const int16_t *>(in.ptr() + offsets_ptr[13] + offset_row), in_stride, dx_ptr[13], dy_ptr[13]), tmp.val[1], 6);
666 tmp.val[1] = vsetq_lane_s16(delta_bilinear_c1(reinterpret_cast<const int16_t *>(in.ptr() + offsets_ptr[15] + offset_row), in_stride, dx_ptr[15], dy_ptr[15]), tmp.val[1], 7);
667
668 vst2q_s16(reinterpret_cast<int16_t *>(out.ptr()), tmp);
669 },
670 in, offsets, dx, dy, out);
671 break;
672 }
Georgios Pinitasc47ef202018-11-16 18:19:43 +0000673#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
674 case DataType::F16:
675 {
676 execute_window_loop(window, [&](const Coordinates & id)
677 {
678 const auto offsets_ptr = reinterpret_cast<const int32_t *>(offsets.ptr());
679 const auto dx_ptr = reinterpret_cast<const float *>(dx.ptr());
680 const auto dy_ptr = reinterpret_cast<const float *>(dy.ptr());
681
682 const int in_yi = std::floor((id.y() + 0.5f) * hr - 0.5f);
683 const int offset_row = in_yi * in_stide_in_bytes;
684
685 float16x8x2_t tmp =
686 {
687 {
688 vdupq_n_f16(0),
689 vdupq_n_f16(0)
690 }
691 };
692
693 tmp.val[0] = vsetq_lane_f16(delta_bilinear_c1(reinterpret_cast<const __fp16 *>(in.ptr() + offsets_ptr[0] + offset_row), in_stride, dx_ptr[0], dy_ptr[0]), tmp.val[0], 0);
694 tmp.val[0] = vsetq_lane_f16(delta_bilinear_c1(reinterpret_cast<const __fp16 *>(in.ptr() + offsets_ptr[2] + offset_row), in_stride, dx_ptr[2], dy_ptr[2]), tmp.val[0], 1);
695 tmp.val[0] = vsetq_lane_f16(delta_bilinear_c1(reinterpret_cast<const __fp16 *>(in.ptr() + offsets_ptr[4] + offset_row), in_stride, dx_ptr[4], dy_ptr[4]), tmp.val[0], 2);
696 tmp.val[0] = vsetq_lane_f16(delta_bilinear_c1(reinterpret_cast<const __fp16 *>(in.ptr() + offsets_ptr[6] + offset_row), in_stride, dx_ptr[6], dy_ptr[6]), tmp.val[0], 3);
697 tmp.val[0] = vsetq_lane_f16(delta_bilinear_c1(reinterpret_cast<const __fp16 *>(in.ptr() + offsets_ptr[8] + offset_row), in_stride, dx_ptr[8], dy_ptr[8]), tmp.val[0], 4);
698 tmp.val[0] = vsetq_lane_f16(delta_bilinear_c1(reinterpret_cast<const __fp16 *>(in.ptr() + offsets_ptr[10] + offset_row), in_stride, dx_ptr[10], dy_ptr[10]), tmp.val[0], 5);
699 tmp.val[0] = vsetq_lane_f16(delta_bilinear_c1(reinterpret_cast<const __fp16 *>(in.ptr() + offsets_ptr[12] + offset_row), in_stride, dx_ptr[12], dy_ptr[12]), tmp.val[0], 6);
700 tmp.val[0] = vsetq_lane_f16(delta_bilinear_c1(reinterpret_cast<const __fp16 *>(in.ptr() + offsets_ptr[14] + offset_row), in_stride, dx_ptr[14], dy_ptr[14]), tmp.val[0], 7);
701
702 tmp.val[1] = vsetq_lane_f16(delta_bilinear_c1(reinterpret_cast<const __fp16 *>(in.ptr() + offsets_ptr[1] + offset_row), in_stride, dx_ptr[1], dy_ptr[1]), tmp.val[1], 0);
703 tmp.val[1] = vsetq_lane_f16(delta_bilinear_c1(reinterpret_cast<const __fp16 *>(in.ptr() + offsets_ptr[3] + offset_row), in_stride, dx_ptr[3], dy_ptr[3]), tmp.val[1], 1);
704 tmp.val[1] = vsetq_lane_f16(delta_bilinear_c1(reinterpret_cast<const __fp16 *>(in.ptr() + offsets_ptr[5] + offset_row), in_stride, dx_ptr[5], dy_ptr[5]), tmp.val[1], 2);
705 tmp.val[1] = vsetq_lane_f16(delta_bilinear_c1(reinterpret_cast<const __fp16 *>(in.ptr() + offsets_ptr[7] + offset_row), in_stride, dx_ptr[7], dy_ptr[7]), tmp.val[1], 3);
706 tmp.val[1] = vsetq_lane_f16(delta_bilinear_c1(reinterpret_cast<const __fp16 *>(in.ptr() + offsets_ptr[9] + offset_row), in_stride, dx_ptr[9], dy_ptr[9]), tmp.val[1], 4);
707 tmp.val[1] = vsetq_lane_f16(delta_bilinear_c1(reinterpret_cast<const __fp16 *>(in.ptr() + offsets_ptr[11] + offset_row), in_stride, dx_ptr[11], dy_ptr[11]), tmp.val[1], 5);
708 tmp.val[1] = vsetq_lane_f16(delta_bilinear_c1(reinterpret_cast<const __fp16 *>(in.ptr() + offsets_ptr[13] + offset_row), in_stride, dx_ptr[13], dy_ptr[13]), tmp.val[1], 6);
709 tmp.val[1] = vsetq_lane_f16(delta_bilinear_c1(reinterpret_cast<const __fp16 *>(in.ptr() + offsets_ptr[15] + offset_row), in_stride, dx_ptr[15], dy_ptr[15]), tmp.val[1], 7);
710
711 vst2q_f16(reinterpret_cast<__fp16 *>(out.ptr()), tmp);
712 },
713 in, offsets, dx, dy, out);
714 break;
715 }
716#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
Georgios Pinitas583137c2017-08-31 18:12:42 +0100717 case DataType::F32:
718 {
719 execute_window_loop(window, [&](const Coordinates & id)
720 {
721 const auto offsets_ptr = reinterpret_cast<const int32_t *>(offsets.ptr());
722 const auto dx_ptr = reinterpret_cast<const float *>(dx.ptr());
723 const auto dy_ptr = reinterpret_cast<const float *>(dy.ptr());
724
725 const int in_yi = std::floor((id.y() + 0.5f) * hr - 0.5f);
726 const int offset_row = in_yi * in_stide_in_bytes;
727
728 float32x4x4_t tmp =
729 {
730 {
731 vdupq_n_f32(0),
732 vdupq_n_f32(0),
733 vdupq_n_f32(0),
734 vdupq_n_f32(0)
735 }
736 };
737
738 tmp.val[0] = vsetq_lane_f32(delta_bilinear_c1(reinterpret_cast<const float *>(in.ptr() + offsets_ptr[0] + offset_row), in_stride, dx_ptr[0], dy_ptr[0]), tmp.val[0], 0);
739 tmp.val[0] = vsetq_lane_f32(delta_bilinear_c1(reinterpret_cast<const float *>(in.ptr() + offsets_ptr[4] + offset_row), in_stride, dx_ptr[4], dy_ptr[4]), tmp.val[0], 1);
740 tmp.val[0] = vsetq_lane_f32(delta_bilinear_c1(reinterpret_cast<const float *>(in.ptr() + offsets_ptr[8] + offset_row), in_stride, dx_ptr[8], dy_ptr[8]), tmp.val[0], 2);
741 tmp.val[0] = vsetq_lane_f32(delta_bilinear_c1(reinterpret_cast<const float *>(in.ptr() + offsets_ptr[12] + offset_row), in_stride, dx_ptr[12], dy_ptr[12]), tmp.val[0], 3);
742
743 tmp.val[1] = vsetq_lane_f32(delta_bilinear_c1(reinterpret_cast<const float *>(in.ptr() + offsets_ptr[1] + offset_row), in_stride, dx_ptr[1], dy_ptr[1]), tmp.val[1], 0);
744 tmp.val[1] = vsetq_lane_f32(delta_bilinear_c1(reinterpret_cast<const float *>(in.ptr() + offsets_ptr[5] + offset_row), in_stride, dx_ptr[5], dy_ptr[5]), tmp.val[1], 1);
745 tmp.val[1] = vsetq_lane_f32(delta_bilinear_c1(reinterpret_cast<const float *>(in.ptr() + offsets_ptr[9] + offset_row), in_stride, dx_ptr[9], dy_ptr[9]), tmp.val[1], 2);
746 tmp.val[1] = vsetq_lane_f32(delta_bilinear_c1(reinterpret_cast<const float *>(in.ptr() + offsets_ptr[13] + offset_row), in_stride, dx_ptr[13], dy_ptr[13]), tmp.val[1], 3);
747
748 tmp.val[2] = vsetq_lane_f32(delta_bilinear_c1(reinterpret_cast<const float *>(in.ptr() + offsets_ptr[2] + offset_row), in_stride, dx_ptr[2], dy_ptr[2]), tmp.val[2], 0);
749 tmp.val[2] = vsetq_lane_f32(delta_bilinear_c1(reinterpret_cast<const float *>(in.ptr() + offsets_ptr[6] + offset_row), in_stride, dx_ptr[6], dy_ptr[6]), tmp.val[2], 1);
750 tmp.val[2] = vsetq_lane_f32(delta_bilinear_c1(reinterpret_cast<const float *>(in.ptr() + offsets_ptr[10] + offset_row), in_stride, dx_ptr[10], dy_ptr[10]), tmp.val[2], 2);
751 tmp.val[2] = vsetq_lane_f32(delta_bilinear_c1(reinterpret_cast<const float *>(in.ptr() + offsets_ptr[14] + offset_row), in_stride, dx_ptr[14], dy_ptr[14]), tmp.val[2], 3);
752
753 tmp.val[3] = vsetq_lane_f32(delta_bilinear_c1(reinterpret_cast<const float *>(in.ptr() + offsets_ptr[3] + offset_row), in_stride, dx_ptr[3], dy_ptr[3]), tmp.val[3], 0);
754 tmp.val[3] = vsetq_lane_f32(delta_bilinear_c1(reinterpret_cast<const float *>(in.ptr() + offsets_ptr[7] + offset_row), in_stride, dx_ptr[7], dy_ptr[7]), tmp.val[3], 1);
755 tmp.val[3] = vsetq_lane_f32(delta_bilinear_c1(reinterpret_cast<const float *>(in.ptr() + offsets_ptr[11] + offset_row), in_stride, dx_ptr[11], dy_ptr[11]), tmp.val[3], 2);
756 tmp.val[3] = vsetq_lane_f32(delta_bilinear_c1(reinterpret_cast<const float *>(in.ptr() + offsets_ptr[15] + offset_row), in_stride, dx_ptr[15], dy_ptr[15]), tmp.val[3], 3);
757
758 vst4q_f32(reinterpret_cast<float *>(out.ptr()), tmp);
759 },
760 in, offsets, dx, dy, out);
761 break;
762 }
763 default:
764 ARM_COMPUTE_ERROR("Not supported");
765 break;
766 }
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100767}
768
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100769void NEScaleKernel::scale_area_nchw(const Window &window)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100770{
771 ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(_input, 1, DataType::U8);
772
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100773 // Don't increment in width/height/channels for the input tensor
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100774 // A pointer to the start of this plane is needed as base for the precomputed offsets
775 Window win_in(window);
776 win_in.set(Window::DimX, Window::Dimension(0, 0, 0));
777 win_in.set(Window::DimY, Window::Dimension(0, 0, 0));
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100778 win_in.set(Window::DimZ, Window::Dimension(0, 0, 0));
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100779
780 Iterator in(_input, win_in);
781 Iterator out(_output, window);
782
783 const auto wr = static_cast<float>(_input->info()->dimension(0)) / static_cast<float>(_output->info()->dimension(0));
784 const auto hr = static_cast<float>(_input->info()->dimension(1)) / static_cast<float>(_output->info()->dimension(1));
785 const auto w = _input->info()->dimension(0);
786 const auto h = _input->info()->dimension(1);
787 const size_t in_stride = _input->info()->strides_in_bytes()[1];
788
789 execute_window_loop(window, [&](const Coordinates & id)
790 {
791 const auto in_ptr = reinterpret_cast<const uint8_t *>(in.ptr());
792
793 uint8x8_t tmp0 = vdup_n_u8(0);
794 tmp0 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x(), id.y()), tmp0, 0);
795 tmp0 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 1, id.y()), tmp0, 1);
796 tmp0 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 2, id.y()), tmp0, 2);
797 tmp0 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 3, id.y()), tmp0, 3);
798 tmp0 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 4, id.y()), tmp0, 4);
799 tmp0 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 5, id.y()), tmp0, 5);
800 tmp0 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 6, id.y()), tmp0, 6);
801 tmp0 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 7, id.y()), tmp0, 7);
802
803 uint8x8_t tmp1 = vdup_n_u8(0);
804 tmp1 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 8, id.y()), tmp1, 0);
805 tmp1 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 9, id.y()), tmp1, 1);
806 tmp1 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 10, id.y()), tmp1, 2);
807 tmp1 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 11, id.y()), tmp1, 3);
808 tmp1 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 12, id.y()), tmp1, 4);
809 tmp1 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 13, id.y()), tmp1, 5);
810 tmp1 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 14, id.y()), tmp1, 6);
811 tmp1 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 15, id.y()), tmp1, 7);
812
813 vst1q_u8(out.ptr(), vcombine_u8(tmp0, tmp1));
814 },
815 in, out);
816}
817
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100818void NEScaleKernel::scale_nhwc(const Window &window)
819{
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100820 // Get data layout and width/height indices
821 const DataLayout data_layout = _input->info()->data_layout();
822 const int idx_channels = get_data_layout_dimension_index(data_layout, DataLayoutDimension::CHANNEL);
823 const int idx_width = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
824 const int idx_height = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
825
826 const size_t input_stride_w = _input->info()->strides_in_bytes()[idx_width];
827 const size_t input_stride_h = _input->info()->strides_in_bytes()[idx_height];
828 const size_t input_stride_c = _input->info()->strides_in_bytes()[idx_channels];
829
830 // Compute the ratio between source height and destination height
831 const auto hr = static_cast<float>(_input->info()->dimension(idx_height)) / static_cast<float>(_output->info()->dimension(idx_height));
832
833 // Don't increment in width/height/channels for the input tensor
834 // A pointer to the start of this plane is needed as base for the precomputed offsets
835 Window win_in(window);
836 win_in.set(Window::DimX, Window::Dimension(0, 0, 0));
837 win_in.set(Window::DimY, Window::Dimension(0, 0, 0));
838 win_in.set(Window::DimZ, Window::Dimension(0, 0, 0));
839
840 switch(_input->info()->data_type())
841 {
842 case DataType::U8:
843 {
844 if(_policy == InterpolationPolicy::NEAREST_NEIGHBOR)
845 {
846 scale_nearest_nhwc_core<uint8_t>(_input, _offsets, _output, hr, window, win_in, input_stride_w, input_stride_h, input_stride_c);
847 }
848 else
849 {
850 scale_bilinear_nhwc_core<uint8_t>(_input, _offsets, _dx, _dy, _output, hr,
851 window, win_in, input_stride_w, input_stride_h, input_stride_c, _border_mode);
852 }
853 break;
854 }
855 case DataType::S16:
856 {
857 if(_policy == InterpolationPolicy::NEAREST_NEIGHBOR)
858 {
859 scale_nearest_nhwc_core<int16_t>(_input, _offsets, _output, hr, window, win_in, input_stride_w, input_stride_h, input_stride_c);
860 }
861 else
862 {
863 scale_bilinear_nhwc_core<int16_t>(_input, _offsets, _dx, _dy, _output, hr,
864 window, win_in, input_stride_w, input_stride_h, input_stride_c, _border_mode);
865 }
866 break;
867 }
Georgios Pinitasc47ef202018-11-16 18:19:43 +0000868#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
869 case DataType::F16:
870 {
871 if(_policy == InterpolationPolicy::NEAREST_NEIGHBOR)
872 {
873 scale_nearest_nhwc_core<float16_t>(_input, _offsets, _output, hr,
874 window, win_in, input_stride_w, input_stride_h, input_stride_c);
875 }
876 else
877 {
878 scale_bilinear_nhwc_core<float16_t>(_input, _offsets, _dx, _dy, _output, hr,
879 window, win_in, input_stride_w, input_stride_h, input_stride_c, _border_mode);
880 }
881 break;
882 }
883#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100884 case DataType::F32:
885 {
886 if(_policy == InterpolationPolicy::NEAREST_NEIGHBOR)
887 {
888 scale_nearest_nhwc_core<float>(_input, _offsets, _output, hr, window, win_in, input_stride_w, input_stride_h, input_stride_c);
889 }
890 else
891 {
892 scale_bilinear_nhwc_core<float>(_input, _offsets, _dx, _dy, _output, hr,
893 window, win_in, input_stride_w, input_stride_h, input_stride_c, _border_mode);
894 }
895 break;
896 }
897 default:
898 ARM_COMPUTE_ERROR("Not supported");
899 break;
900 }
901}
902
Georgios Pinitas20b43132018-05-14 16:05:23 +0100903Status NEScaleKernel::validate(const ITensorInfo *input, const ITensorInfo *dx, const ITensorInfo *dy,
904 const ITensorInfo *offsets, ITensorInfo *output, InterpolationPolicy policy,
905 BorderMode border_mode, SamplingPolicy sampling_policy)
906{
907 BorderSize border_size(1);
908 if(input->data_layout() == DataLayout::NHWC)
909 {
910 border_size = (border_mode == BorderMode::CONSTANT && policy == InterpolationPolicy::BILINEAR) ? BorderSize(1, 0, 0, 0) : BorderSize(0);
911 }
912
913 ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, dx, dy, offsets, output, policy, border_mode, sampling_policy));
914 ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window(input->clone().get(),
915 dx != nullptr ? dx->clone().get() : nullptr,
916 dy != nullptr ? dy->clone().get() : nullptr,
917 offsets != nullptr ? offsets->clone().get() : nullptr,
918 output->clone().get(),
919 policy, border_mode == BorderMode::UNDEFINED, sampling_policy, border_size)
920 .first);
921
922 return Status{};
923}
924
Moritz Pflanzerc186b572017-09-07 09:48:04 +0100925void NEScaleKernel::run(const Window &window, const ThreadInfo &info)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100926{
Moritz Pflanzerc186b572017-09-07 09:48:04 +0100927 ARM_COMPUTE_UNUSED(info);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100928 ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this);
929 ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(INEKernel::window(), window);
930 ARM_COMPUTE_ERROR_ON(_func == nullptr);
931
932 (this->*_func)(window);
933}
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100934} // namespace arm_compute