blob: 94f5a181021c65d4655a794869a84b6c3fd8612b [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01002 * Copyright (c) 2016-2020 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/Helpers.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010029#include "arm_compute/core/Window.h"
Sang-Hoon Park94d50512020-07-02 10:49:39 +010030#include "arm_compute/core/utils/misc/Rounding.h"
Georgios Pinitas393fa4c2018-05-08 15:54:53 +010031#include "arm_compute/core/utils/misc/Utility.h"
Georgios Pinitasddb93bb2020-10-02 16:38:59 +010032#include "src/core/NEON/wrapper/wrapper.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010033
Sang-Hoon Park3687ee12020-06-24 13:34:04 +010034#include "src/core/utils/ScaleUtils.h"
35
Anthony Barbier6ff3b192017-09-04 18:44:23 +010036#include <arm_neon.h>
Manuel Bottinifc2f6d02020-08-26 16:28:38 +010037#include <map>
Anthony Barbier6ff3b192017-09-04 18:44:23 +010038
Georgios Pinitas393fa4c2018-05-08 15:54:53 +010039namespace arm_compute
40{
41namespace
42{
Manuel Bottinifc2f6d02020-08-26 16:28:38 +010043inline float compute_bilinear(float a00, float a01, float a10, float a11, float dx_val, float dy_val)
44{
45 const float dx1_val = 1.0f - dx_val;
46 const float dy1_val = 1.0f - dy_val;
47
48 const float w1 = dx1_val * dy1_val;
49 const float w2 = dx_val * dy1_val;
50 const float w3 = dx1_val * dy_val;
51 const float w4 = dx_val * dy_val;
52 return a00 * w1 + a01 * w2 + a10 * w3 + a11 * w4;
53}
54
Georgios Pinitas20b43132018-05-14 16:05:23 +010055Status validate_arguments(const ITensorInfo *input, const ITensorInfo *dx, const ITensorInfo *dy,
Sang-Hoon Parkc2617982020-05-20 22:13:47 +010056 const ITensorInfo *offsets, ITensorInfo *output, const ScaleKernelInfo &info)
Georgios Pinitas393fa4c2018-05-08 15:54:53 +010057{
Georgios Pinitasc47ef202018-11-16 18:19:43 +000058 ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(input);
Sheri Zhang359c48e2020-04-30 22:53:39 +010059 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8, DataType::S16, DataType::F16, DataType::F32, DataType::QASYMM8, DataType::QASYMM8_SIGNED);
Georgios Pinitas20b43132018-05-14 16:05:23 +010060 ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(output);
61 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, output);
62 ARM_COMPUTE_RETURN_ERROR_ON(output == input);
Sang-Hoon Parkc2617982020-05-20 22:13:47 +010063 ARM_COMPUTE_RETURN_ERROR_ON(info.sampling_policy != SamplingPolicy::CENTER && info.sampling_policy != SamplingPolicy::TOP_LEFT);
Sang-Hoon Parkc2617982020-05-20 22:13:47 +010064 ARM_COMPUTE_UNUSED(info.constant_border_value);
Manuel Bottinifc2f6d02020-08-26 16:28:38 +010065 ARM_COMPUTE_RETURN_ERROR_ON_MSG(info.use_padding, "Padding is not supported");
Georgios Pinitas20b43132018-05-14 16:05:23 +010066
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +000067 const DataLayout data_layout = input->data_layout();
68 const auto width_index = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
69 const auto height_index = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
70 const auto output_width = output->dimension(width_index);
71 const auto output_height = output->dimension(height_index);
72 ARM_COMPUTE_RETURN_ERROR_ON(output_width == 0);
73 ARM_COMPUTE_RETURN_ERROR_ON(output_height == 0);
Georgios Pinitas20b43132018-05-14 16:05:23 +010074
Sang-Hoon Parkc2617982020-05-20 22:13:47 +010075 if(info.interpolation_policy == InterpolationPolicy::NEAREST_NEIGHBOR)
Georgios Pinitas20b43132018-05-14 16:05:23 +010076 {
77 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(offsets, 1, DataType::S32);
78 }
79
Sang-Hoon Parkc2617982020-05-20 22:13:47 +010080 if(info.interpolation_policy == InterpolationPolicy::BILINEAR)
Georgios Pinitas20b43132018-05-14 16:05:23 +010081 {
82 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(offsets, 1, DataType::S32);
83 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(dx, 1, DataType::F32);
84 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(dy, 1, DataType::F32);
Sang-Hoon Parkf025a772020-05-26 11:11:32 +010085 }
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +000086
Manuel Bottinifc2f6d02020-08-26 16:28:38 +010087 ARM_COMPUTE_RETURN_ERROR_ON(info.align_corners && !scale_utils::is_align_corners_allowed_sampling_policy(info.sampling_policy));
Georgios Pinitas20b43132018-05-14 16:05:23 +010088
Sang-Hoon Parkc2617982020-05-20 22:13:47 +010089 if(info.interpolation_policy == InterpolationPolicy::AREA)
Georgios Pinitas20b43132018-05-14 16:05:23 +010090 {
91 ARM_COMPUTE_RETURN_ERROR_ON(data_layout != DataLayout::NCHW);
Vidhya Sudhan Loganathan3ac2f3a2019-01-17 15:16:19 +000092 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8);
Georgios Pinitas20b43132018-05-14 16:05:23 +010093 }
94
95 return Status{};
96}
Georgios Pinitas393fa4c2018-05-08 15:54:53 +010097} // namespace
Anthony Barbier6ff3b192017-09-04 18:44:23 +010098
99NEScaleKernel::NEScaleKernel()
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100100 : _func(nullptr), _offsets(nullptr), _dx(nullptr), _dy(nullptr), _input(nullptr), _output(nullptr), _policy(), _border_mode(), _constant_border_value(PixelValue()), _sampling_offset(0),
101 _align_corners(false)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100102{
103}
104
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100105void NEScaleKernel::configure(const ITensor *input, const ITensor *dx, const ITensor *dy, const ITensor *offsets,
Sang-Hoon Parkc2617982020-05-20 22:13:47 +0100106 ITensor *output, const ScaleKernelInfo &info)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100107{
Georgios Pinitas20b43132018-05-14 16:05:23 +0100108 ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
Georgios Pinitas20b43132018-05-14 16:05:23 +0100109 // Perform validation step
110 ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(),
111 dx != nullptr ? dx->info() : nullptr,
112 dy != nullptr ? dy->info() : nullptr,
113 offsets != nullptr ? offsets->info() : nullptr,
114 output->info(),
Sang-Hoon Parkc2617982020-05-20 22:13:47 +0100115 info));
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100116
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100117 // Get data layout and width/height indices
118 const DataLayout data_layout = input->info()->data_layout();
119 const int idx_width = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
120 const int idx_height = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100121
George Wort05398a92019-01-25 15:38:33 +0000122 _input = input;
123 _output = output;
124 _offsets = offsets;
125 _dx = dx;
126 _dy = dy;
Sang-Hoon Parkc2617982020-05-20 22:13:47 +0100127 _policy = info.interpolation_policy;
Sang-Hoon Parkc2617982020-05-20 22:13:47 +0100128 _border_mode = info.border_mode;
129 _constant_border_value = info.constant_border_value;
Michele Di Giorgio7a81d2a2020-07-30 14:52:16 +0100130 _align_corners = info.align_corners;
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100131
Sang-Hoon Parkc2617982020-05-20 22:13:47 +0100132 if(info.sampling_policy == SamplingPolicy::CENTER)
Vidhya Sudhan Loganathan3ac2f3a2019-01-17 15:16:19 +0000133 {
134 _sampling_offset = 0.5f;
135 }
136
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100137 // Compute the ratio between source width/height and destination width/height
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100138 const auto wr = scale_utils::calculate_resize_ratio(input->info()->dimension(idx_width), output->info()->dimension(idx_width), _align_corners);
139 const auto hr = scale_utils::calculate_resize_ratio(input->info()->dimension(idx_height), output->info()->dimension(idx_height), _align_corners);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100140
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100141 // Area interpolation behaves as Nearest Neighbour in case of up-sampling
Sang-Hoon Parkc2617982020-05-20 22:13:47 +0100142 const auto policy_to_use = (info.interpolation_policy == InterpolationPolicy::AREA && wr <= 1.f && hr <= 1.f) ? InterpolationPolicy::NEAREST_NEIGHBOR : _policy;
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100143
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100144 if(_border_mode == BorderMode::UNDEFINED)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100145 {
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100146 _border_mode = BorderMode::CONSTANT;
147 _constant_border_value = PixelValue();
148 }
149 std::string function_to_call("scale_");
150 function_to_call += string_from_data_type(_input->info()->data_type()) + "_";
151 function_to_call += string_from_data_layout(_input->info()->data_layout()) + "_";
152 function_to_call += string_from_interpolation_policy(policy_to_use);
153
154 static std::map<std::string, ScaleFunctionPtr> map_function =
155 {
156 { "scale_U8_NCHW_AREA_CONSTANT", &NEScaleKernel::scale_area_nchw_u8 },
157
158 { "scale_U8_NCHW_BILINEAR", &NEScaleKernel::scale_bilinear_nchw<uint8_t> },
159 { "scale_U8_NCHW_NEAREST_NEIGHBOUR", &NEScaleKernel::scale_nearest_nchw<uint8_t> },
160
161 { "scale_U8_NHWC_BILINEAR", &NEScaleKernel::scale_bilinear_nhwc<uint8_t> },
162 { "scale_U8_NHWC_NEAREST_NEIGHBOUR", &NEScaleKernel::scale_nearest_nhwc<uint8_t> },
163
164 { "scale_QASYMM8_NCHW_BILINEAR", &NEScaleKernel::scale_bilinear_qasymm<uint8_t> },
165 { "scale_QASYMM8_NCHW_NEAREST_NEIGHBOUR", &NEScaleKernel::scale_nearest_nchw<uint8_t> },
166
167 { "scale_QASYMM8_NHWC_BILINEAR", &NEScaleKernel::scale_bilinear_qasymm<uint8_t> },
168 { "scale_QASYMM8_NHWC_NEAREST_NEIGHBOUR", &NEScaleKernel::scale_nearest_nhwc<uint8_t> },
169
170 { "scale_QASYMM8_SIGNED_NCHW_BILINEAR", &NEScaleKernel::scale_bilinear_qasymm<int8_t> },
171 { "scale_QASYMM8_SIGNED_NCHW_NEAREST_NEIGHBOUR", &NEScaleKernel::scale_nearest_nchw<uint8_t> },
172
173 { "scale_QASYMM8_SIGNED_NHWC_BILINEAR", &NEScaleKernel::scale_bilinear_qasymm<int8_t> },
174 { "scale_QASYMM8_SIGNED_NHWC_NEAREST_NEIGHBOUR", &NEScaleKernel::scale_nearest_nhwc<uint8_t> },
175
176 { "scale_S16_NCHW_BILINEAR", &NEScaleKernel::scale_bilinear_nchw<int16_t> },
177 { "scale_S16_NCHW_NEAREST_NEIGHBOUR", &NEScaleKernel::scale_nearest_nchw<uint16_t> },
178
179 { "scale_S16_NHWC_BILINEAR", &NEScaleKernel::scale_bilinear_nhwc<int16_t> },
180 { "scale_S16_NHWC_NEAREST_NEIGHBOUR", &NEScaleKernel::scale_nearest_nhwc<uint16_t> },
181
182#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
183 { "scale_F16_NCHW_BILINEAR", &NEScaleKernel::scale_bilinear_nchw<float16_t> },
184 { "scale_F16_NCHW_NEAREST_NEIGHBOUR", &NEScaleKernel::scale_nearest_nchw<uint16_t> },
185
186 { "scale_F16_NHWC_BILINEAR", &NEScaleKernel::scale_bilinear_nhwc<float16_t> },
187 { "scale_F16_NHWC_NEAREST_NEIGHBOUR", &NEScaleKernel::scale_nearest_nhwc<uint16_t> },
188#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
189
190 { "scale_F32_NCHW_BILINEAR", &NEScaleKernel::scale_bilinear_nchw<float> },
191 { "scale_F32_NCHW_NEAREST_NEIGHBOUR", &NEScaleKernel::scale_nearest_nchw<float> },
192
193 { "scale_F32_NHWC_BILINEAR", &NEScaleKernel::scale_bilinear_nhwc<float> },
194 { "scale_F32_NHWC_NEAREST_NEIGHBOUR", &NEScaleKernel::scale_nearest_nhwc<float> },
195 };
196 auto it = map_function.find(function_to_call);
197 if(it != map_function.end())
198 {
199 _func = it->second;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100200 }
201
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100202 // Configure window
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100203 Window win = calculate_max_window(*output->info(), Steps());
204 Coordinates coord;
205 coord.set_num_dimensions(output->info()->num_dimensions());
206 output->info()->set_valid_region(ValidRegion(coord, output->info()->tensor_shape()));
207 INEKernel::configure(win);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100208}
209
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100210template <typename T>
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100211void NEScaleKernel::scale_nearest_nchw(const Window &window)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100212{
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100213 const size_t in_dim_x = _input->info()->dimension(0);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100214
215 // Compute the ratio between source height and destination height
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100216 const auto hr = scale_utils::calculate_resize_ratio(_input->info()->dimension(1), _output->info()->dimension(1), _align_corners);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100217
218 // Don't increment in X and Y direction for the input tensor
219 // A pointer to the start of this plane is needed as base for the precomputed offsets
220 Window win_in(window);
221 win_in.set(Window::DimX, Window::Dimension(0, 0, 0));
222 win_in.set(Window::DimY, Window::Dimension(0, 0, 0));
223
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100224 // Set offsets window
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100225 Window win_off;
226 win_off.set(Window::DimX, window[Window::DimX]);
227 win_off.set(Window::DimY, window[Window::DimY]);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100228 for(size_t d = Window::DimZ; d < _offsets->info()->num_dimensions(); ++d)
229 {
230 win_off.set(d, Window::Dimension(0, 0, 0));
231 }
232
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100233 // Create iterators
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100234 Iterator in(_input, win_in);
235 Iterator out(_output, window);
236 Iterator offsets(_offsets, win_off);
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100237 execute_window_loop(window, [&](const Coordinates & id)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100238 {
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100239 const auto offsets_ptr = reinterpret_cast<const int32_t *>(offsets.ptr());
240 const auto in_yi = static_cast<int32_t>(_align_corners ? utils::rounding::round_half_away_from_zero((id.y() + _sampling_offset) * hr) : std::floor((id.y() + _sampling_offset) * hr));
241 const int32_t offset_row = in_yi * in_dim_x;
242 *reinterpret_cast<T *>(out.ptr()) = *(reinterpret_cast<const T *>(in.ptr()) + offsets_ptr[0] + offset_row);
243 },
244 in, offsets, out);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100245}
246
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100247template <typename T>
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100248void NEScaleKernel::scale_bilinear_nchw(const Window &window)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100249{
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100250 // Compute the ratio between source height and destination height
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100251 const auto hr = scale_utils::calculate_resize_ratio(_input->info()->dimension(1), _output->info()->dimension(1), _align_corners);
252 Window win_off;
253 win_off.set(Window::DimX, window.x());
254 win_off.set(Window::DimY, window.y());
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100255
256 // Don't increment in X and Y direction for the input tensor
257 // A pointer to the start of this plane is needed as base for the precomputed offsets
258 Window win_in(window);
259 win_in.set(Window::DimX, Window::Dimension(0, 0, 0));
260 win_in.set(Window::DimY, Window::Dimension(0, 0, 0));
261
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100262 for(size_t d = Window::DimZ; d < _offsets->info()->num_dimensions(); ++d)
263 {
264 win_off.set(d, Window::Dimension(0, 0, 0));
265 }
266
267 Iterator in(_input, win_in);
268 Iterator out(_output, window);
269 Iterator offsets(_offsets, win_off);
270 Iterator dx(_dx, win_off);
271 Iterator dy(_dy, win_off);
272
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100273 const int32_t in_dim_w = _input->info()->dimension(0);
274 const int32_t in_dim_h = _input->info()->dimension(1);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100275
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100276 if(_border_mode == BorderMode::CONSTANT)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100277 {
Georgios Pinitasc47ef202018-11-16 18:19:43 +0000278#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100279 using ConstType = typename std::conditional<std::is_same<T, float16_t>::value, half, T>::type;
280#else /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
281 using ConstType = T;
Georgios Pinitasc47ef202018-11-16 18:19:43 +0000282#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100283 const T const_border_value = static_cast<T>(_constant_border_value.get<ConstType>());
284 execute_window_loop(window, [&](const Coordinates & id)
Georgios Pinitas583137c2017-08-31 18:12:42 +0100285 {
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100286 const int32_t index_h = std::floor((id.y() + _sampling_offset) * hr - _sampling_offset);
287 const auto index_w = *(reinterpret_cast<const int32_t *>(offsets.ptr()));
288 const auto dx_val = *(reinterpret_cast<const float *>(dx.ptr()));
289 const auto dy_val = *(reinterpret_cast<const float *>(dy.ptr()));
290 const auto pixel_row_ptr = reinterpret_cast<const T *>(in.ptr());
Georgios Pinitas583137c2017-08-31 18:12:42 +0100291
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100292 const auto a00 = (0 <= index_w && index_w < in_dim_w && 0 <= index_h && index_h < in_dim_h) ? (*(pixel_row_ptr + index_w + index_h * in_dim_w)) : const_border_value;
293 const auto a01 = (-1 <= index_w && index_w < in_dim_w - 1 && 0 <= index_h && index_h < in_dim_h) ? (*(pixel_row_ptr + index_w + 1 + index_h * in_dim_w)) : const_border_value;
294 const auto a10 = (0 <= index_w && index_w < in_dim_w && -1 <= index_h
295 && index_h < in_dim_h - 1) ?
296 (*(pixel_row_ptr + index_w + index_h * in_dim_w + in_dim_w)) :
297 const_border_value;
298 const auto a11 = (-1 <= index_w && index_w < in_dim_w - 1 && -1 <= index_h
299 && index_h < in_dim_h - 1) ?
300 (*(pixel_row_ptr + index_w + 1 + index_h * in_dim_w + in_dim_w)) :
301 const_border_value;
Georgios Pinitas583137c2017-08-31 18:12:42 +0100302
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100303 *reinterpret_cast<T *>(out.ptr()) = static_cast<T>(compute_bilinear(a00, a01, a10, a11, dx_val, dy_val));
304 },
305 in, offsets, dx, dy, out);
306 }
307 else if(_border_mode == BorderMode::REPLICATE)
308 {
309 execute_window_loop(window, [&](const Coordinates & id)
310 {
311 const int index_h = std::floor((id.y() + _sampling_offset) * hr - _sampling_offset);
312 const auto index_w = *(reinterpret_cast<const int32_t *>(offsets.ptr()));
313 const auto dx_val = *(reinterpret_cast<const float *>(dx.ptr()));
314 const auto dy_val = *(reinterpret_cast<const float *>(dy.ptr()));
315 const auto pixel_row_ptr = reinterpret_cast<const T *>(in.ptr());
Georgios Pinitas583137c2017-08-31 18:12:42 +0100316
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100317 auto clamped_x = utility::clamp<int>(index_w, 0, in_dim_w - 1);
318 auto clamped_x1 = utility::clamp<int>(index_w + 1, 0, in_dim_w - 1);
319 auto clamped_y = utility::clamp<int>(index_h, 0, in_dim_h - 1);
320 auto clamped_y1 = utility::clamp<int>(index_h + 1, 0, in_dim_h - 1);
Georgios Pinitas583137c2017-08-31 18:12:42 +0100321
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100322 const auto a00 = *(pixel_row_ptr + clamped_x + clamped_y * in_dim_w);
323 const auto a01 = *(pixel_row_ptr + clamped_x1 + clamped_y * in_dim_w);
324 const auto a10 = *(pixel_row_ptr + clamped_x + clamped_y1 * in_dim_w);
325 const auto a11 = *(pixel_row_ptr + clamped_x1 + clamped_y1 * in_dim_w);
Georgios Pinitas583137c2017-08-31 18:12:42 +0100326
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100327 *reinterpret_cast<T *>(out.ptr()) = static_cast<T>(compute_bilinear(a00, a01, a10, a11, dx_val, dy_val));
328 },
329 in, offsets, dx, dy, out);
330 }
331 else
332 {
333 ARM_COMPUTE_ERROR("Not implemented");
Georgios Pinitas583137c2017-08-31 18:12:42 +0100334 }
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100335}
336
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100337void NEScaleKernel::scale_area_nchw_u8(const Window &window)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100338{
339 ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(_input, 1, DataType::U8);
340
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100341 // Don't increment in width/height/channels for the input tensor
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100342 // A pointer to the start of this plane is needed as base for the precomputed offsets
343 Window win_in(window);
344 win_in.set(Window::DimX, Window::Dimension(0, 0, 0));
345 win_in.set(Window::DimY, Window::Dimension(0, 0, 0));
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100346 win_in.set(Window::DimZ, Window::Dimension(0, 0, 0));
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100347
348 Iterator in(_input, win_in);
349 Iterator out(_output, window);
350
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100351 const auto wr = scale_utils::calculate_resize_ratio(_input->info()->dimension(0), _output->info()->dimension(0), _align_corners);
352 const auto hr = scale_utils::calculate_resize_ratio(_input->info()->dimension(1), _output->info()->dimension(1), _align_corners);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100353 const auto w = _input->info()->dimension(0);
354 const auto h = _input->info()->dimension(1);
355 const size_t in_stride = _input->info()->strides_in_bytes()[1];
356
357 execute_window_loop(window, [&](const Coordinates & id)
358 {
359 const auto in_ptr = reinterpret_cast<const uint8_t *>(in.ptr());
360
361 uint8x8_t tmp0 = vdup_n_u8(0);
362 tmp0 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x(), id.y()), tmp0, 0);
363 tmp0 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 1, id.y()), tmp0, 1);
364 tmp0 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 2, id.y()), tmp0, 2);
365 tmp0 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 3, id.y()), tmp0, 3);
366 tmp0 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 4, id.y()), tmp0, 4);
367 tmp0 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 5, id.y()), tmp0, 5);
368 tmp0 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 6, id.y()), tmp0, 6);
369 tmp0 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 7, id.y()), tmp0, 7);
370
371 uint8x8_t tmp1 = vdup_n_u8(0);
372 tmp1 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 8, id.y()), tmp1, 0);
373 tmp1 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 9, id.y()), tmp1, 1);
374 tmp1 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 10, id.y()), tmp1, 2);
375 tmp1 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 11, id.y()), tmp1, 3);
376 tmp1 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 12, id.y()), tmp1, 4);
377 tmp1 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 13, id.y()), tmp1, 5);
378 tmp1 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 14, id.y()), tmp1, 6);
379 tmp1 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 15, id.y()), tmp1, 7);
380
381 vst1q_u8(out.ptr(), vcombine_u8(tmp0, tmp1));
382 },
383 in, out);
384}
385
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100386template <typename T>
387void NEScaleKernel::scale_nearest_nhwc(const Window &window)
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100388{
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100389 const size_t in_dim_w = _input->info()->dimension(1);
390 const size_t in_dim_h = _input->info()->dimension(2);
391 const size_t in_dim_c = _input->info()->dimension(0);
392 const size_t in_dim_wc = in_dim_w * in_dim_c;
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100393
394 // Compute the ratio between source height and destination height
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100395 const auto hr = scale_utils::calculate_resize_ratio(in_dim_h, _output->info()->dimension(2), _align_corners);
396 const auto window_start_x = static_cast<int32_t>(window.x().start());
397 const auto window_end_x = static_cast<int32_t>(window.x().end());
398 const int window_step_x = 16 / sizeof(T);
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100399
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100400 Window win(window);
401 win.set(Window::DimX, Window::Dimension(0, 1, 1));
402 // Don't increment in X and Y direction for the input tensor
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100403 // A pointer to the start of this plane is needed as base for the precomputed offsets
404 Window win_in(window);
405 win_in.set(Window::DimX, Window::Dimension(0, 0, 0));
406 win_in.set(Window::DimY, Window::Dimension(0, 0, 0));
407 win_in.set(Window::DimZ, Window::Dimension(0, 0, 0));
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100408 Iterator in(_input, win_in);
409 Iterator out(_output, win);
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100410
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100411 execute_window_loop(win, [&](const Coordinates & id)
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100412 {
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100413 const int32_t offset = *reinterpret_cast<const int32_t *>(_offsets->ptr_to_element(Coordinates(id.y(), id.z()))) * in_dim_c;
414 const auto in_hi = static_cast<int>(_align_corners ? utils::rounding::round_half_away_from_zero((id.z() + _sampling_offset) * hr) : std::floor((id.z() + _sampling_offset) * hr));
415 const int offset_row = in_hi * in_dim_wc;
416 int32_t x = window_start_x;
417 for(; x <= window_end_x - window_step_x; x += window_step_x)
Sheri Zhang359c48e2020-04-30 22:53:39 +0100418 {
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100419 wrapper::vstore(reinterpret_cast<T *>(out.ptr()) + x,
420 wrapper::vloadq(reinterpret_cast<const T *>(in.ptr()) + offset + offset_row + x));
Sheri Zhang359c48e2020-04-30 22:53:39 +0100421 }
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100422 for(; x < window_end_x; ++x)
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100423 {
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100424 *(reinterpret_cast<T *>(out.ptr()) + x) = *(reinterpret_cast<const T *>(in.ptr()) + offset + offset_row + x);
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100425 }
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100426 },
427 in, out);
428}
429
430template <typename T>
431void NEScaleKernel::scale_bilinear_nhwc(const Window &window)
432{
433 // Compute the ratio between source height and destination height
434 const auto hr = scale_utils::calculate_resize_ratio(_input->info()->dimension(2), _output->info()->dimension(2), _align_corners);
435
436 Iterator out(_output, window);
437 const int in_dim_c = _input->info()->dimension(0);
438 const int in_dim_w = _input->info()->dimension(1);
439 const int in_dim_h = _input->info()->dimension(2);
440 const int input_wc = in_dim_c * in_dim_w;
441
442 // Don't increment in Y and Z direction for the input tensor
443 // A pointer to the start of this plane is needed as base for the precomputed offsets
444 Window win_in(window);
445 win_in.set(Window::DimY, Window::Dimension(0, 0, 0));
446 win_in.set(Window::DimZ, Window::Dimension(0, 0, 0));
447 Iterator in(_input, win_in);
448
449 if(_border_mode == BorderMode::CONSTANT)
450 {
Georgios Pinitasc47ef202018-11-16 18:19:43 +0000451#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100452 using ConstType = typename std::conditional<std::is_same<T, float16_t>::value, half, T>::type;
453#else /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
454 using ConstType = T;
Georgios Pinitasc47ef202018-11-16 18:19:43 +0000455#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100456 const T const_border_value = static_cast<T>(_constant_border_value.get<ConstType>());
457 execute_window_loop(window, [&](const Coordinates & id)
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100458 {
Manuel Bottinifc2f6d02020-08-26 16:28:38 +0100459 const auto offset = *reinterpret_cast<const int32_t *>(_offsets->ptr_to_element(Coordinates(id.y(), id.z())));
460 const auto dx_val = *reinterpret_cast<const float *>(_dx->ptr_to_element(Coordinates(id.y(), id.z())));
461 const auto dy_val = *reinterpret_cast<const float *>(_dy->ptr_to_element(Coordinates(id.y(), id.z())));
462 const int32_t in_hi = std::floor((id.z() + _sampling_offset) * hr - _sampling_offset);
463 const T *in_ptr = reinterpret_cast<const T *>(in.ptr()) + offset * in_dim_c + in_hi * input_wc;
464
465 const auto a00 = (0 <= offset && offset < in_dim_w && 0 <= in_hi && in_hi < in_dim_h) ? *in_ptr : const_border_value;
466 const auto a01 = (-1 <= offset && offset < in_dim_w - 1 && 0 <= in_hi && in_hi < in_dim_h) ? *(in_ptr + in_dim_c) : const_border_value;
467 const auto a10 = (0 <= offset && offset < in_dim_w && -1 <= in_hi && in_hi < in_dim_h - 1) ? *(in_ptr + input_wc) : const_border_value;
468 const auto a11 = (-1 <= offset && offset < in_dim_w - 1 && -1 <= in_hi && in_hi < in_dim_h - 1) ? *(in_ptr + in_dim_c + input_wc) : const_border_value;
469
470 *reinterpret_cast<T *>(out.ptr()) = static_cast<T>(compute_bilinear(a00, a01, a10, a11, dx_val, dy_val));
471 },
472 in, out);
473 }
474 else if(_border_mode == BorderMode::REPLICATE)
475 {
476 execute_window_loop(window, [&](const Coordinates & id)
477 {
478 const auto offset = *reinterpret_cast<const int32_t *>(_offsets->ptr_to_element(Coordinates(id.y(), id.z())));
479 const auto dx_val = *reinterpret_cast<const float *>(_dx->ptr_to_element(Coordinates(id.y(), id.z())));
480 const auto dy_val = *reinterpret_cast<const float *>(_dy->ptr_to_element(Coordinates(id.y(), id.z())));
481 const int in_hi = std::floor((id.z() + _sampling_offset) * hr - _sampling_offset);
482
483 auto clamped_w = utility::clamp<int>(offset, 0, in_dim_w - 1);
484 auto clamped_w1 = utility::clamp<int>(offset + 1, 0, in_dim_w - 1);
485 auto clamped_h = utility::clamp<int>(in_hi, 0, in_dim_h - 1);
486 auto clamped_h1 = utility::clamp<int>(in_hi + 1, 0, in_dim_h - 1);
487
488 const auto a00 = *(reinterpret_cast<const T *>(in.ptr()) + clamped_w * in_dim_c + clamped_h * input_wc);
489 const auto a01 = *(reinterpret_cast<const T *>(in.ptr()) + clamped_w1 * in_dim_c + clamped_h * input_wc);
490 const auto a10 = *(reinterpret_cast<const T *>(in.ptr()) + clamped_w * in_dim_c + clamped_h1 * input_wc);
491 const auto a11 = *(reinterpret_cast<const T *>(in.ptr()) + clamped_w1 * in_dim_c + clamped_h1 * input_wc);
492
493 *reinterpret_cast<T *>(out.ptr()) = static_cast<T>(compute_bilinear(a00, a01, a10, a11, dx_val, dy_val));
494 },
495 in, out);
496 }
497 else
498 {
499 ARM_COMPUTE_ERROR("Not implemented");
500 }
501}
502
503template <typename T>
504void NEScaleKernel::scale_bilinear_qasymm(const Window &window)
505{
506 // Get data layout and width/height indices
507 const DataLayout data_layout = _input->info()->data_layout();
508 const int idx_width = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
509 const int idx_height = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
510
511 // Compute the ratio between source height and destination height
512 const auto hr = scale_utils::calculate_resize_ratio(_input->info()->dimension(idx_height), _output->info()->dimension(idx_height), _align_corners);
513 Window win_off;
514 win_off.set(Window::DimX, Window::Dimension(0, 0, 0));
515 win_off.set(Window::DimY, Window::Dimension(0, 0, 0));
516
517 // Don't increment in X and Y direction for the input tensor
518 // A pointer to the start of this plane is needed as base for the precomputed offsets
519 Window win_in(window);
520 win_in.set(idx_width, Window::Dimension(0, 0, 0));
521 win_in.set(idx_height, Window::Dimension(0, 0, 0));
522
523 for(size_t d = Window::DimZ; d < _offsets->info()->num_dimensions(); ++d)
524 {
525 win_off.set(d, Window::Dimension(0, 0, 0));
526 }
527
528 Iterator in(_input, win_in);
529 Iterator out(_output, window);
530
531 const int32_t in_dim_w = _input->info()->dimension(idx_width);
532 const int32_t in_dim_h = _input->info()->dimension(idx_height);
533 const int32_t stride_w = _input->info()->strides_in_bytes()[idx_width];
534 const int32_t stride_h = _input->info()->strides_in_bytes()[idx_height];
535
536 const UniformQuantizationInfo iq_info = _input->info()->quantization_info().uniform();
537 const UniformQuantizationInfo oq_info = _output->info()->quantization_info().uniform();
538
539 if(_border_mode == BorderMode::CONSTANT)
540 {
541#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
542 using ConstType = typename std::conditional<std::is_same<T, float16_t>::value, half, T>::type;
543#else /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
544 using ConstType = T;
545#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
546 const T const_border_value = static_cast<T>(_constant_border_value.get<ConstType>());
547 execute_window_loop(window, [&](const Coordinates & id)
548 {
549 const int32_t index_h = std::floor((id[idx_height] + _sampling_offset) * hr - _sampling_offset);
550 const int32_t index_w = *(reinterpret_cast<const int32_t *>(_offsets->ptr_to_element(Coordinates(id[idx_width], id[idx_height]))));
551 const auto dx_val = *(reinterpret_cast<const float *>(_dx->ptr_to_element(Coordinates(id[idx_width], id[idx_height]))));
552 const auto dy_val = *(reinterpret_cast<const float *>(_dy->ptr_to_element(Coordinates(id[idx_width], id[idx_height]))));
553 const auto pixel_row_ptr = reinterpret_cast<const T *>(in.ptr());
554
555 const auto a00 = (0 <= index_w && index_w < in_dim_w && 0 <= index_h && index_h < in_dim_h) ?
556 (*(pixel_row_ptr + index_w * stride_w + index_h * stride_h)) :
557 const_border_value;
558 const auto a01 = (-1 <= index_w && index_w < in_dim_w - 1 && 0 <= index_h && index_h < in_dim_h) ?
559 (*(pixel_row_ptr + (index_w + 1) * stride_w + index_h * stride_h)) :
560 const_border_value;
561 const auto a10 = (0 <= index_w && index_w < in_dim_w && -1 <= index_h && index_h < in_dim_h - 1) ?
562 (*(pixel_row_ptr + index_w * stride_w + (index_h + 1) * stride_h)) :
563 const_border_value;
564 const auto a11 = (-1 <= index_w && index_w < in_dim_w - 1 && -1 <= index_h && index_h < in_dim_h - 1) ?
565 (*(pixel_row_ptr + (index_w + 1) * stride_w + (index_h + 1) * stride_h)) :
566 const_border_value;
567
568 const float inp00 = Qasymm8QuantizationHelper<T>::dequantize(a00, iq_info);
569 const float inp01 = Qasymm8QuantizationHelper<T>::dequantize(a01, iq_info);
570 const float inp10 = Qasymm8QuantizationHelper<T>::dequantize(a10, iq_info);
571 const float inp11 = Qasymm8QuantizationHelper<T>::dequantize(a11, iq_info);
572 *reinterpret_cast<T *>(out.ptr()) = Qasymm8QuantizationHelper<T>::quantize(compute_bilinear(inp00, inp01, inp10, inp11, dx_val, dy_val), oq_info);
573 },
574 in, out);
575 }
576 else if(_border_mode == BorderMode::REPLICATE)
577 {
578 execute_window_loop(window, [&](const Coordinates & id)
579 {
580 const int index_h = std::floor((id[idx_height] + _sampling_offset) * hr - _sampling_offset);
581 const int32_t index_w = *(reinterpret_cast<const int32_t *>(_offsets->ptr_to_element(Coordinates(id[idx_width], id[idx_height]))));
582 const auto dx_val = *(reinterpret_cast<const float *>(_dx->ptr_to_element(Coordinates(id[idx_width], id[idx_height]))));
583 const auto dy_val = *(reinterpret_cast<const float *>(_dy->ptr_to_element(Coordinates(id[idx_width], id[idx_height]))));
584 const auto pixel_row_ptr = reinterpret_cast<const T *>(in.ptr());
585
586 auto clamped_w = utility::clamp<int>(index_w, 0, in_dim_w - 1);
587 auto clamped_w1 = utility::clamp<int>(index_w + 1, 0, in_dim_w - 1);
588 auto clamped_h = utility::clamp<int>(index_h, 0, in_dim_h - 1);
589 auto clamped_h1 = utility::clamp<int>(index_h + 1, 0, in_dim_h - 1);
590
591 const auto a00 = *(pixel_row_ptr + clamped_w * stride_w + clamped_h * stride_h);
592 const auto a01 = *(pixel_row_ptr + clamped_w1 * stride_w + clamped_h * stride_h);
593 const auto a10 = *(pixel_row_ptr + clamped_w * stride_w + clamped_h1 * stride_h);
594 const auto a11 = *(pixel_row_ptr + clamped_w1 * stride_w + clamped_h1 * stride_h);
595
596 const float inp00 = Qasymm8QuantizationHelper<T>::dequantize(a00, iq_info);
597 const float inp01 = Qasymm8QuantizationHelper<T>::dequantize(a01, iq_info);
598 const float inp10 = Qasymm8QuantizationHelper<T>::dequantize(a10, iq_info);
599 const float inp11 = Qasymm8QuantizationHelper<T>::dequantize(a11, iq_info);
600 *reinterpret_cast<T *>(out.ptr()) = Qasymm8QuantizationHelper<T>::quantize(compute_bilinear(inp00, inp01, inp10, inp11, dx_val, dy_val), oq_info);
601 },
602 in, out);
603 }
604 else
605 {
606 ARM_COMPUTE_ERROR("Not implemented");
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100607 }
608}
609
Georgios Pinitas20b43132018-05-14 16:05:23 +0100610Status NEScaleKernel::validate(const ITensorInfo *input, const ITensorInfo *dx, const ITensorInfo *dy,
Sang-Hoon Parkc2617982020-05-20 22:13:47 +0100611 const ITensorInfo *offsets, ITensorInfo *output, const ScaleKernelInfo &info)
Georgios Pinitas20b43132018-05-14 16:05:23 +0100612{
Sang-Hoon Parkc2617982020-05-20 22:13:47 +0100613 ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, dx, dy, offsets, output, info));
Georgios Pinitas20b43132018-05-14 16:05:23 +0100614 return Status{};
615}
616
Moritz Pflanzerc186b572017-09-07 09:48:04 +0100617void NEScaleKernel::run(const Window &window, const ThreadInfo &info)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100618{
Moritz Pflanzerc186b572017-09-07 09:48:04 +0100619 ARM_COMPUTE_UNUSED(info);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100620 ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this);
621 ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(INEKernel::window(), window);
622 ARM_COMPUTE_ERROR_ON(_func == nullptr);
623
624 (this->*_func)(window);
625}
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100626} // namespace arm_compute