blob: 17ff4bb676fe3fe226c9f080d865e8f6079c7708 [file] [log] [blame]
Sheri Zhang23adc4c2021-01-05 12:48:45 +00001/*
Gunes Bayir0eed3052022-09-04 21:00:10 +01002 * Copyright (c) 2021-2022 Arm Limited.
Sheri Zhang23adc4c2021-01-05 12:48:45 +00003 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
Sheri Zhang360f5762021-01-20 12:20:20 +000024#ifndef SRC_CORE_NEON_KERNELS_SCALE_LIST_H
25#define SRC_CORE_NEON_KERNELS_SCALE_LIST_H
26
Sheri Zhang23adc4c2021-01-05 12:48:45 +000027#include "arm_compute/core/Helpers.h"
28#include "arm_compute/core/ITensorPack.h"
29#include "arm_compute/core/Window.h"
30#include "src/core/NEON/NEMath.h"
31#include "src/core/NEON/wrapper/wrapper.h"
Sheri Zhang23adc4c2021-01-05 12:48:45 +000032#include "src/core/helpers/ScaleHelpers.h"
33#include "src/core/utils/ScaleUtils.h"
34#include "support/Rounding.h"
35
Sheri Zhang23adc4c2021-01-05 12:48:45 +000036namespace arm_compute
37{
Sheri Zhang360f5762021-01-20 12:20:20 +000038namespace cpu
Sheri Zhang23adc4c2021-01-05 12:48:45 +000039{
Sheri Zhang360f5762021-01-20 12:20:20 +000040#define DECLARE_SCALE_KERNEL(func_name) \
41 void func_name(const ITensor *src, ITensor *dst, const ITensor *offsets, const ITensor *dx, const ITensor *dy, \
42 InterpolationPolicy policy, BorderMode border_mode, PixelValue constant_border_value, float sampling_offset, \
43 bool align_corners, const Window &window)
44
Gian Marco Iodice8b8405a2021-10-01 17:48:02 +010045DECLARE_SCALE_KERNEL(s16_neon_scale);
46DECLARE_SCALE_KERNEL(u8_neon_scale);
Sheri Zhang360f5762021-01-20 12:20:20 +000047DECLARE_SCALE_KERNEL(qasymm8_neon_scale);
48DECLARE_SCALE_KERNEL(qasymm8_signed_neon_scale);
49
50#undef DECLARE_SCALE_KERNEL
51
52template <typename T>
53void nearest_neon_scale(const ITensor *src, ITensor *dst, const ITensor *offsets, float sampling_offset,
54 bool align_corners, const Window &window)
Sheri Zhang23adc4c2021-01-05 12:48:45 +000055{
Gian Marco Iodice8b8405a2021-10-01 17:48:02 +010056 ARM_COMPUTE_UNUSED(offsets);
Sheri Zhang23adc4c2021-01-05 12:48:45 +000057
Gian Marco Iodice8b8405a2021-10-01 17:48:02 +010058 // Compute the ratio between source and destination dimensions
59 const float scale_x = scale_utils::calculate_resize_ratio(src->info()->dimension(1), dst->info()->dimension(1), align_corners);
60 const float scale_y = scale_utils::calculate_resize_ratio(src->info()->dimension(2), dst->info()->dimension(2), align_corners);
Sheri Zhang23adc4c2021-01-05 12:48:45 +000061
Gian Marco Iodice8b8405a2021-10-01 17:48:02 +010062 const int in_stride_y = src->info()->strides_in_bytes()[1];
63 const int in_stride_z = src->info()->strides_in_bytes()[2];
64 const int in_stride_w = src->info()->strides_in_bytes()[3];
65 const int out_stride_y = dst->info()->strides_in_bytes()[1];
66 const int out_stride_z = dst->info()->strides_in_bytes()[2];
67 const int out_stride_w = dst->info()->strides_in_bytes()[3];
68 const int out_dim_ch = dst->info()->dimension(0);
69 const int step_cout = 16 / sizeof(T);
Sheri Zhang23adc4c2021-01-05 12:48:45 +000070
Gian Marco Iodice8b8405a2021-10-01 17:48:02 +010071 Window window_execution = window;
72 window_execution.set(Window::DimX, Window::Dimension(0, 1, 1));
73 Window win_in_out(window);
74 win_in_out.set(Window::DimY, Window::Dimension(0, 0, 0));
75 win_in_out.set(Window::DimZ, Window::Dimension(0, 0, 0));
76 Iterator in(src, win_in_out);
77 Iterator out(dst, win_in_out);
Sheri Zhang23adc4c2021-01-05 12:48:45 +000078
Gian Marco Iodice8b8405a2021-10-01 17:48:02 +010079 const int xo_start = window_execution.y().start();
80 const int xo_end = window_execution.y().end();
81 const int xo_step = window_execution.y().step();
82 const int yo_start = window_execution.z().start();
83 const int yo_end = window_execution.z().end();
84 const int yo_step = window_execution.z().step();
85 const int bo_start = window_execution[3].start();
86 const int bo_end = window_execution[3].end();
87 const int bo_step = window_execution[3].step();
88
89 for(int bo = bo_start; bo < bo_end; bo += bo_step)
Sheri Zhang23adc4c2021-01-05 12:48:45 +000090 {
Gian Marco Iodice8b8405a2021-10-01 17:48:02 +010091 const uint8_t *in_ptr_base = in.ptr() + bo * in_stride_w;
92 uint8_t *out_ptr_base = out.ptr() + bo * out_stride_w;
Sheri Zhang23adc4c2021-01-05 12:48:45 +000093
Gian Marco Iodice8b8405a2021-10-01 17:48:02 +010094 for(int yo = yo_start; yo < yo_end; yo += yo_step)
Sheri Zhang23adc4c2021-01-05 12:48:45 +000095 {
Gian Marco Iodice8b8405a2021-10-01 17:48:02 +010096 // Floating-point coordinate
97 float yi_f = ((yo + sampling_offset) * scale_y);
98 int yi = 0;
99 if(align_corners)
100 {
101 yi = utils::rounding::round_half_away_from_zero(yi_f);
102 }
103 else
104 {
105 yi = static_cast<int>(std::floor(yi_f));
106 }
107
108 for(int xo = xo_start; xo < xo_end; xo += xo_step)
109 {
110 // Floating-point coordinate
111 float xi_f = ((xo + sampling_offset) * scale_x);
112 int xi = 0;
113 if(align_corners)
114 {
115 xi = utils::rounding::round_half_away_from_zero(xi_f);
116 }
117 else
118 {
119 xi = static_cast<int>(std::floor(xi_f));
120 }
121
122 const uint8_t *in_ptr = in_ptr_base + xi * in_stride_y + yi * in_stride_z;
123 uint8_t *out_ptr = out_ptr_base + xo * out_stride_y + yo * out_stride_z;
124
125 int cout = 0;
126 for(; cout <= (out_dim_ch - step_cout); cout += step_cout)
127 {
128 auto out0 = wrapper::vloadq(reinterpret_cast<const T *>(in_ptr + cout * sizeof(T)));
129 wrapper::vstore(reinterpret_cast<T *>(out_ptr + cout * sizeof(T)), out0);
130 }
131
132 for(; cout < out_dim_ch; ++cout)
133 {
Gunes Bayir0eed3052022-09-04 21:00:10 +0100134 auto out0 = *(reinterpret_cast<const T *>(in_ptr + cout * sizeof(T)));
Gian Marco Iodice8b8405a2021-10-01 17:48:02 +0100135 *(reinterpret_cast<T *>(out_ptr + cout * sizeof(T))) = out0;
136 }
137 }
Sheri Zhang23adc4c2021-01-05 12:48:45 +0000138 }
Gian Marco Iodice8b8405a2021-10-01 17:48:02 +0100139 }
Sheri Zhang23adc4c2021-01-05 12:48:45 +0000140}
141
Sheri Zhang360f5762021-01-20 12:20:20 +0000142template <typename T>
143void bilinear_neon_scale(const ITensor *src, ITensor *dst, const ITensor *offsets, const ITensor *dx, const ITensor *dy,
144 BorderMode border_mode, PixelValue constant_border_value, float sampling_offset,
145 bool align_corners, const Window &window)
Sheri Zhang23adc4c2021-01-05 12:48:45 +0000146{
Gian Marco Iodice8b8405a2021-10-01 17:48:02 +0100147 ARM_COMPUTE_UNUSED(offsets);
148 ARM_COMPUTE_UNUSED(dx);
149 ARM_COMPUTE_UNUSED(dy);
150 using ExactTagType = typename wrapper::traits::neon_bitvector_tag_t<T, wrapper::traits::BitWidth::W128>;
Sheri Zhang23adc4c2021-01-05 12:48:45 +0000151
Gian Marco Iodice8b8405a2021-10-01 17:48:02 +0100152 // Compute the ratio between source and destination dimensions
153 const float scale_x = scale_utils::calculate_resize_ratio(src->info()->dimension(1), dst->info()->dimension(1), align_corners);
154 const float scale_y = scale_utils::calculate_resize_ratio(src->info()->dimension(2), dst->info()->dimension(2), align_corners);
155
156 const int in_stride_y = src->info()->strides_in_bytes()[1];
157 const int in_stride_z = src->info()->strides_in_bytes()[2];
158 const int in_stride_w = src->info()->strides_in_bytes()[3];
159 const int out_stride_y = dst->info()->strides_in_bytes()[1];
160 const int out_stride_z = dst->info()->strides_in_bytes()[2];
161 const int out_stride_w = dst->info()->strides_in_bytes()[3];
Sheri Zhang23adc4c2021-01-05 12:48:45 +0000162 const int in_dim_w = src->info()->dimension(1);
163 const int in_dim_h = src->info()->dimension(2);
Gian Marco Iodice8b8405a2021-10-01 17:48:02 +0100164 const int out_dim_ch = dst->info()->dimension(0);
165 const int step_cout = 16 / sizeof(T);
Sheri Zhang23adc4c2021-01-05 12:48:45 +0000166
Gian Marco Iodice8b8405a2021-10-01 17:48:02 +0100167 Window window_execution = window;
168 window_execution.set(Window::DimX, Window::Dimension(0, 1, 1));
169 Window win_in_out(window);
170 win_in_out.set(Window::DimY, Window::Dimension(0, 0, 0));
171 win_in_out.set(Window::DimZ, Window::Dimension(0, 0, 0));
172 Iterator in(src, win_in_out);
173 Iterator out(dst, win_in_out);
174
175 const int xo_start = window_execution.y().start();
176 const int xo_end = window_execution.y().end();
177 const int xo_step = window_execution.y().step();
178 const int yo_start = window_execution.z().start();
179 const int yo_end = window_execution.z().end();
180 const int yo_step = window_execution.z().step();
181 const int bo_start = window_execution[3].start();
182 const int bo_end = window_execution[3].end();
183 const int bo_step = window_execution[3].step();
Sheri Zhang23adc4c2021-01-05 12:48:45 +0000184
185 if(border_mode == BorderMode::CONSTANT)
186 {
Sheri Zhang360f5762021-01-20 12:20:20 +0000187#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
188 using ConstType = typename std::conditional<std::is_same<T, float16_t>::value, half, T>::type;
189#else /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
190 using ConstType = T;
191#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
192 const T const_border_value = static_cast<T>(constant_border_value.get<ConstType>());
Gian Marco Iodice8b8405a2021-10-01 17:48:02 +0100193
194 for(int bo = bo_start; bo < bo_end; bo += bo_step)
Sheri Zhang23adc4c2021-01-05 12:48:45 +0000195 {
Gian Marco Iodice8b8405a2021-10-01 17:48:02 +0100196 const uint8_t *in_ptr_base = in.ptr() + bo * in_stride_w;
197 uint8_t *out_ptr_base = out.ptr() + bo * out_stride_w;
Sheri Zhang23adc4c2021-01-05 12:48:45 +0000198
Gian Marco Iodice8b8405a2021-10-01 17:48:02 +0100199 for(int yo = yo_start; yo < yo_end; yo += yo_step)
200 {
201 // Floating-point coordinate
202 const float yi_f = ((yo + sampling_offset) * scale_y - sampling_offset);
203 // Integer coordinate
204 const auto yi = static_cast<int>(std::floor(yi_f));
205 // Weight for the y coordinate
206 const auto a1 = (yi_f - static_cast<float>(yi));
207 const auto b1 = (1.f - a1);
Sheri Zhang23adc4c2021-01-05 12:48:45 +0000208
Gian Marco Iodice8b8405a2021-10-01 17:48:02 +0100209 for(int xo = xo_start; xo < xo_end; xo += xo_step)
210 {
211 // Floating-point coordinate
212 const float xi_f = ((xo + sampling_offset) * scale_x - sampling_offset);
213 // Integer coordinate
214 const auto xi = static_cast<int>(std::floor(xi_f));
215 // Weight for the x coordinate
216 const auto a = (xi_f - static_cast<float>(xi));
217 const auto b = (1.f - a);
218
219 const auto s00_s = static_cast<T>(b * b1);
220 const auto s01_s = static_cast<T>(a * b1);
221 const auto s10_s = static_cast<T>(b * a1);
222 const auto s11_s = static_cast<T>(a * a1);
223
224 const uint8_t *in_ptr = in_ptr_base + xi * in_stride_y + yi * in_stride_z;
225 uint8_t *out_ptr = out_ptr_base + xo * out_stride_y + yo * out_stride_z;
226
227 int cout = 0;
228 for(; cout <= (out_dim_ch - step_cout); cout += step_cout)
229 {
230 auto in00 = wrapper::vdup_n(static_cast<T>(const_border_value), ExactTagType{});
231 auto in01 = wrapper::vdup_n(static_cast<T>(const_border_value), ExactTagType{});
232 auto in10 = wrapper::vdup_n(static_cast<T>(const_border_value), ExactTagType{});
233 auto in11 = wrapper::vdup_n(static_cast<T>(const_border_value), ExactTagType{});
234 if((yi >= 0) && (yi < in_dim_h))
235 {
236 if((xi >= 0) && (xi < in_dim_w))
237 {
238 in00 = wrapper::vloadq(reinterpret_cast<const T *>(in_ptr + cout * sizeof(T)));
239 }
240 if(((xi + 1) >= 0) && ((xi + 1) < in_dim_w))
241 {
242 in01 = wrapper::vloadq(reinterpret_cast<const T *>(in_ptr + cout * sizeof(T) + in_stride_y));
243 }
244 }
245 if(((yi + 1) >= 0) && ((yi + 1) < in_dim_h))
246 {
247 if((xi >= 0) && (xi < in_dim_w))
248 {
249 in10 = wrapper::vloadq(reinterpret_cast<const T *>(in_ptr + cout * sizeof(T) + in_stride_z));
250 }
251 if(((xi + 1) >= 0) && ((xi + 1) < in_dim_w))
252 {
253 in11 = wrapper::vloadq(reinterpret_cast<const T *>(in_ptr + cout * sizeof(T) + in_stride_y + in_stride_z));
254 }
255 }
256
257 const auto s00 = wrapper::vdup_n(s00_s, ExactTagType{});
258 const auto s01 = wrapper::vdup_n(s01_s, ExactTagType{});
259 const auto s10 = wrapper::vdup_n(s10_s, ExactTagType{});
260 const auto s11 = wrapper::vdup_n(s11_s, ExactTagType{});
261 auto out0 = wrapper::vdup_n(static_cast<T>(0), ExactTagType{});
262 out0 = wrapper::vmla(out0, in00, s00);
263 out0 = wrapper::vmla(out0, in01, s01);
264 out0 = wrapper::vmla(out0, in10, s10);
265 out0 = wrapper::vmla(out0, in11, s11);
266 wrapper::vstore(reinterpret_cast<T *>(out_ptr + cout * sizeof(T)), out0);
267 }
268
269 for(; cout < out_dim_ch; ++cout)
270 {
271 auto in00 = static_cast<T>(const_border_value);
272 auto in01 = static_cast<T>(const_border_value);
273 auto in10 = static_cast<T>(const_border_value);
274 auto in11 = static_cast<T>(const_border_value);
275 if((yi >= 0) && (yi < in_dim_h))
276 {
277 if((xi >= 0) && (xi < in_dim_w))
278 {
279 in00 = *(reinterpret_cast<const T *>(in_ptr + cout * sizeof(T)));
280 }
281 if(((xi + 1) >= 0) && ((xi + 1) < in_dim_w))
282 {
283 in01 = *(reinterpret_cast<const T *>(in_ptr + cout * sizeof(T) + in_stride_y));
284 }
285 }
286 if(((yi + 1) >= 0) && ((yi + 1) < in_dim_h))
287 {
288 if((xi >= 0) && (xi < in_dim_w))
289 {
290 in10 = *(reinterpret_cast<const T *>(in_ptr + cout * sizeof(T) + in_stride_z));
291 }
292 if(((xi + 1) >= 0) && ((xi + 1) < in_dim_w))
293 {
294 in11 = *(reinterpret_cast<const T *>(in_ptr + cout * sizeof(T) + in_stride_y + in_stride_z));
295 }
296 }
297 auto out0 = static_cast<T>(0);
298 out0 += in00 * s00_s;
299 out0 += in01 * s01_s;
300 out0 += in10 * s10_s;
301 out0 += in11 * s11_s;
302 *(reinterpret_cast<T *>(out_ptr + cout * sizeof(T))) = out0;
303 }
304 }
305 }
306 }
Sheri Zhang23adc4c2021-01-05 12:48:45 +0000307 }
308 else if(border_mode == BorderMode::REPLICATE)
309 {
Gian Marco Iodice8b8405a2021-10-01 17:48:02 +0100310 for(int bo = bo_start; bo < bo_end; bo += bo_step)
Sheri Zhang23adc4c2021-01-05 12:48:45 +0000311 {
Gian Marco Iodice8b8405a2021-10-01 17:48:02 +0100312 const uint8_t *in_ptr = in.ptr() + bo * in_stride_w;
313 uint8_t *out_ptr = out.ptr() + bo * out_stride_w;
Sheri Zhang23adc4c2021-01-05 12:48:45 +0000314
Gian Marco Iodice8b8405a2021-10-01 17:48:02 +0100315 for(int yo = yo_start; yo < yo_end; yo += yo_step)
316 {
317 // Floating-point coordinate
318 const float yi_f = ((yo + sampling_offset) * scale_y - sampling_offset);
319 // Integer coordinate
320 const auto yi = static_cast<int>(std::floor(yi_f));
321 // Weight for the y coordinate
322 const auto a1 = (yi_f - static_cast<float>(yi));
323 const auto b1 = (1.f - a1);
Sheri Zhang23adc4c2021-01-05 12:48:45 +0000324
Gunes Bayir0eed3052022-09-04 21:00:10 +0100325 const int yi0 = utility::clamp<int>(yi, 0, in_dim_h - 1);
326 const int yi1 = utility::clamp<int>(yi + 1, 0, in_dim_h - 1);
Sheri Zhang23adc4c2021-01-05 12:48:45 +0000327
Gunes Bayir0eed3052022-09-04 21:00:10 +0100328 const int yi0_offset = yi0 * in_stride_z;
329 const int yi1_offset = yi1 * in_stride_z;
330
331 const int y_offset = yo * out_stride_z;
Gian Marco Iodice8b8405a2021-10-01 17:48:02 +0100332 for(int xo = xo_start; xo < xo_end; xo += xo_step)
333 {
334 // Floating-point coordinate
335 const float xi_f = ((xo + sampling_offset) * scale_x - sampling_offset);
336 // Integer coordinate
337 const auto xi = static_cast<int>(std::floor(xi_f));
338 // Weight for the x coordinate
339 const auto a = (xi_f - static_cast<float>(xi));
340 const auto b = (1.f - a);
341
342 const auto s00_s = static_cast<T>(b * b1);
343 const auto s01_s = static_cast<T>(a * b1);
344 const auto s10_s = static_cast<T>(b * a1);
345 const auto s11_s = static_cast<T>(a * a1);
346
Gunes Bayir0eed3052022-09-04 21:00:10 +0100347 const auto s00 = wrapper::vdup_n(s00_s, ExactTagType{});
348 const auto s01 = wrapper::vdup_n(s01_s, ExactTagType{});
349 const auto s10 = wrapper::vdup_n(s10_s, ExactTagType{});
350 const auto s11 = wrapper::vdup_n(s11_s, ExactTagType{});
351
352 const int xi0 = utility::clamp<int>(xi, 0, in_dim_w - 1);
353 const int xi1 = utility::clamp<int>(xi + 1, 0, in_dim_w - 1);
354
355 const int xi0_offset = xi0 * in_stride_y;
356 const int xi1_offset = xi1 * in_stride_y;
357
358 const int offset = xo * out_stride_y + y_offset;
Gian Marco Iodice8b8405a2021-10-01 17:48:02 +0100359
360 int cout = 0;
361 for(; cout <= (out_dim_ch - step_cout); cout += step_cout)
362 {
Gunes Bayir0eed3052022-09-04 21:00:10 +0100363 auto in00 = wrapper::vloadq(reinterpret_cast<const T *>(in_ptr + cout * sizeof(T) + xi0_offset + yi0_offset));
364 auto in01 = wrapper::vloadq(reinterpret_cast<const T *>(in_ptr + cout * sizeof(T) + xi1_offset + yi0_offset));
365 auto in10 = wrapper::vloadq(reinterpret_cast<const T *>(in_ptr + cout * sizeof(T) + xi0_offset + yi1_offset));
366 auto in11 = wrapper::vloadq(reinterpret_cast<const T *>(in_ptr + cout * sizeof(T) + xi1_offset + yi1_offset));
Gian Marco Iodice8b8405a2021-10-01 17:48:02 +0100367
Gunes Bayir0eed3052022-09-04 21:00:10 +0100368 auto out0 = wrapper::vmul(in00, s00);
369 out0 = wrapper::vmla(out0, in01, s01);
370 out0 = wrapper::vmla(out0, in10, s10);
371 out0 = wrapper::vmla(out0, in11, s11);
372 wrapper::vstore(reinterpret_cast<T *>(out_ptr + offset + cout * sizeof(T)), out0);
Gian Marco Iodice8b8405a2021-10-01 17:48:02 +0100373 }
374
375 for(; cout < out_dim_ch; ++cout)
376 {
Gunes Bayir0eed3052022-09-04 21:00:10 +0100377 T in00 = *(reinterpret_cast<const T *>(in_ptr + cout * sizeof(T) + xi0_offset + yi0_offset));
378 T in01 = *(reinterpret_cast<const T *>(in_ptr + cout * sizeof(T) + xi1_offset + yi0_offset));
379 T in10 = *(reinterpret_cast<const T *>(in_ptr + cout * sizeof(T) + xi0_offset + yi1_offset));
380 T in11 = *(reinterpret_cast<const T *>(in_ptr + cout * sizeof(T) + xi1_offset + yi1_offset));
381
382 T out0 = in00 * s00_s;
Gian Marco Iodice8b8405a2021-10-01 17:48:02 +0100383 out0 += in01 * s01_s;
384 out0 += in10 * s10_s;
385 out0 += in11 * s11_s;
Gunes Bayir0eed3052022-09-04 21:00:10 +0100386 *(reinterpret_cast<T *>(out_ptr + offset + cout * sizeof(T))) = out0;
Gian Marco Iodice8b8405a2021-10-01 17:48:02 +0100387 }
388 }
389 }
390 }
Sheri Zhang23adc4c2021-01-05 12:48:45 +0000391 }
392 else
393 {
394 ARM_COMPUTE_ERROR("Not implemented");
395 }
396}
Sheri Zhang360f5762021-01-20 12:20:20 +0000397
398template <typename T>
399void common_neon_scale(const ITensor *src, ITensor *dst, const ITensor *offsets, const ITensor *dx, const ITensor *dy,
400 InterpolationPolicy policy, BorderMode border_mode, PixelValue constant_border_value, float sampling_offset,
401 bool align_corners, const Window &window)
Sheri Zhang23adc4c2021-01-05 12:48:45 +0000402{
403 if(policy == InterpolationPolicy::BILINEAR)
404 {
Sheri Zhang360f5762021-01-20 12:20:20 +0000405 bilinear_neon_scale<T>(src, dst, offsets, dx, dy, border_mode, constant_border_value, sampling_offset, align_corners, window);
Sheri Zhang23adc4c2021-01-05 12:48:45 +0000406 }
407 else if(policy == InterpolationPolicy::NEAREST_NEIGHBOR)
408 {
Sheri Zhang360f5762021-01-20 12:20:20 +0000409 nearest_neon_scale<T>(src, dst, offsets, sampling_offset, align_corners, window);
Sheri Zhang23adc4c2021-01-05 12:48:45 +0000410 }
411}
412} // namespace cpu
Sheri Zhang360f5762021-01-20 12:20:20 +0000413} // namespace arm_compute
414
415#endif /* SRC_CORE_NEON_KERNELS_SCALE_LIST_H */