Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1 | /* |
Pablo Marquez Tello | 48c0ed9 | 2023-05-05 15:02:32 +0100 | [diff] [blame] | 2 | * Copyright (c) 2016-2023 Arm Limited. |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to |
| 8 | * deal in the Software without restriction, including without limitation the |
| 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 10 | * sell copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in all |
| 14 | * copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | * SOFTWARE. |
| 23 | */ |
Georgios Pinitas | 7891a73 | 2021-08-20 21:39:25 +0100 | [diff] [blame] | 24 | #include "src/cpu/kernels/CpuScaleKernel.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 25 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 26 | #include "arm_compute/core/Helpers.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 27 | #include "arm_compute/core/Window.h" |
Sheri Zhang | 23adc4c | 2021-01-05 12:48:45 +0000 | [diff] [blame] | 28 | #include "src/core/common/Registrars.h" |
Sang-Hoon Park | 68dd25f | 2020-10-19 16:00:11 +0100 | [diff] [blame] | 29 | #include "src/core/helpers/ScaleHelpers.h" |
| 30 | #include "src/core/helpers/WindowHelpers.h" |
Georgios Pinitas | 7891a73 | 2021-08-20 21:39:25 +0100 | [diff] [blame] | 31 | #include "src/cpu/kernels/scale/neon/list.h" |
| 32 | #include "src/cpu/kernels/scale/sve/list.h" |
Sang-Hoon Park | 68dd25f | 2020-10-19 16:00:11 +0100 | [diff] [blame] | 33 | #include "support/Rounding.h" |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 34 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 35 | #include <arm_neon.h> |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 36 | #include <map> |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 37 | |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 38 | namespace arm_compute |
| 39 | { |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 40 | namespace cpu |
| 41 | { |
| 42 | namespace kernels |
| 43 | { |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 44 | namespace |
| 45 | { |
Giorgio Arena | 5ae8d80 | 2021-11-18 18:02:13 +0000 | [diff] [blame] | 46 | static const std::vector<CpuScaleKernel::ScaleKernel> available_kernels = |
Sheri Zhang | 23adc4c | 2021-01-05 12:48:45 +0000 | [diff] [blame] | 47 | { |
Sheri Zhang | 23adc4c | 2021-01-05 12:48:45 +0000 | [diff] [blame] | 48 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 49 | "sve_fp16_scale", |
Gunes Bayir | 53929b1 | 2022-08-11 12:15:39 +0100 | [diff] [blame] | 50 | [](const ScaleKernelDataTypeISASelectorData & data) |
| 51 | { |
| 52 | return data.dt == DataType::F16 && data.isa.sve && data.isa.fp16 && data.interpolation_policy != InterpolationPolicy::BILINEAR; |
| 53 | }, |
Georgios Pinitas | bdcdc39 | 2021-04-22 16:42:03 +0100 | [diff] [blame] | 54 | REGISTER_FP16_SVE(arm_compute::cpu::fp16_sve_scale) |
Sheri Zhang | 23adc4c | 2021-01-05 12:48:45 +0000 | [diff] [blame] | 55 | }, |
| 56 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 57 | "sve_fp32_scale", |
Gunes Bayir | 53929b1 | 2022-08-11 12:15:39 +0100 | [diff] [blame] | 58 | [](const ScaleKernelDataTypeISASelectorData & data) |
| 59 | { |
| 60 | return data.dt == DataType::F32 && data.isa.sve && data.interpolation_policy != InterpolationPolicy::BILINEAR; |
| 61 | }, |
Georgios Pinitas | bdcdc39 | 2021-04-22 16:42:03 +0100 | [diff] [blame] | 62 | REGISTER_FP32_SVE(arm_compute::cpu::fp32_sve_scale) |
Sheri Zhang | 23adc4c | 2021-01-05 12:48:45 +0000 | [diff] [blame] | 63 | }, |
| 64 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 65 | "sve_qu8_scale", |
Gunes Bayir | c4f2743 | 2022-09-11 15:59:19 +0100 | [diff] [blame] | 66 | [](const ScaleKernelDataTypeISASelectorData & data) |
| 67 | { |
| 68 | return data.dt == DataType::QASYMM8 && data.isa.sve && data.interpolation_policy != InterpolationPolicy::BILINEAR; |
| 69 | }, |
Georgios Pinitas | bdcdc39 | 2021-04-22 16:42:03 +0100 | [diff] [blame] | 70 | REGISTER_QASYMM8_SVE(arm_compute::cpu::qasymm8_sve_scale) |
Sheri Zhang | 23adc4c | 2021-01-05 12:48:45 +0000 | [diff] [blame] | 71 | }, |
| 72 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 73 | "sve_qs8_scale", |
Gunes Bayir | c4f2743 | 2022-09-11 15:59:19 +0100 | [diff] [blame] | 74 | [](const ScaleKernelDataTypeISASelectorData & data) |
| 75 | { |
| 76 | return data.dt == DataType::QASYMM8_SIGNED && data.isa.sve && data.interpolation_policy != InterpolationPolicy::BILINEAR; |
| 77 | }, |
Georgios Pinitas | bdcdc39 | 2021-04-22 16:42:03 +0100 | [diff] [blame] | 78 | REGISTER_QASYMM8_SIGNED_SVE(arm_compute::cpu::qasymm8_signed_sve_scale) |
Sheri Zhang | 23adc4c | 2021-01-05 12:48:45 +0000 | [diff] [blame] | 79 | }, |
| 80 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 81 | "sve_u8_scale", |
Gunes Bayir | c4f2743 | 2022-09-11 15:59:19 +0100 | [diff] [blame] | 82 | [](const ScaleKernelDataTypeISASelectorData & data) |
| 83 | { |
| 84 | return data.dt == DataType::U8 && data.isa.sve && data.interpolation_policy != InterpolationPolicy::BILINEAR; |
| 85 | }, |
Georgios Pinitas | bdcdc39 | 2021-04-22 16:42:03 +0100 | [diff] [blame] | 86 | REGISTER_INTEGER_SVE(arm_compute::cpu::u8_sve_scale) |
Sheri Zhang | 23adc4c | 2021-01-05 12:48:45 +0000 | [diff] [blame] | 87 | }, |
| 88 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 89 | "sve_s16_scale", |
Gunes Bayir | c4f2743 | 2022-09-11 15:59:19 +0100 | [diff] [blame] | 90 | [](const ScaleKernelDataTypeISASelectorData & data) |
| 91 | { |
| 92 | return data.dt == DataType::S16 && data.isa.sve && data.interpolation_policy != InterpolationPolicy::BILINEAR; |
| 93 | }, |
Georgios Pinitas | bdcdc39 | 2021-04-22 16:42:03 +0100 | [diff] [blame] | 94 | REGISTER_INTEGER_SVE(arm_compute::cpu::s16_sve_scale) |
Sheri Zhang | 23adc4c | 2021-01-05 12:48:45 +0000 | [diff] [blame] | 95 | }, |
Sheri Zhang | 23adc4c | 2021-01-05 12:48:45 +0000 | [diff] [blame] | 96 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 97 | "neon_fp16_scale", |
Gunes Bayir | 53929b1 | 2022-08-11 12:15:39 +0100 | [diff] [blame] | 98 | [](const ScaleKernelDataTypeISASelectorData & data) { return data.dt == DataType::F16 && data.isa.fp16; }, |
Sheri Zhang | 360f576 | 2021-01-20 12:20:20 +0000 | [diff] [blame] | 99 | REGISTER_FP16_NEON(arm_compute::cpu::common_neon_scale<float16_t>) |
Sheri Zhang | 23adc4c | 2021-01-05 12:48:45 +0000 | [diff] [blame] | 100 | }, |
Sheri Zhang | 23adc4c | 2021-01-05 12:48:45 +0000 | [diff] [blame] | 101 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 102 | "neon_fp32_scale", |
Gunes Bayir | 53929b1 | 2022-08-11 12:15:39 +0100 | [diff] [blame] | 103 | [](const ScaleKernelDataTypeISASelectorData & data) { return data.dt == DataType::F32; }, |
Sheri Zhang | 360f576 | 2021-01-20 12:20:20 +0000 | [diff] [blame] | 104 | REGISTER_FP32_NEON(arm_compute::cpu::common_neon_scale<float>) |
Sheri Zhang | 23adc4c | 2021-01-05 12:48:45 +0000 | [diff] [blame] | 105 | }, |
| 106 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 107 | "neon_qu8_scale", |
Gunes Bayir | 53929b1 | 2022-08-11 12:15:39 +0100 | [diff] [blame] | 108 | [](const ScaleKernelDataTypeISASelectorData & data) { return data.dt == DataType::QASYMM8; }, |
Sheri Zhang | 23adc4c | 2021-01-05 12:48:45 +0000 | [diff] [blame] | 109 | REGISTER_QASYMM8_NEON(arm_compute::cpu::qasymm8_neon_scale) |
| 110 | }, |
| 111 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 112 | "neon_qs8_scale", |
Gunes Bayir | 53929b1 | 2022-08-11 12:15:39 +0100 | [diff] [blame] | 113 | [](const ScaleKernelDataTypeISASelectorData & data) { return data.dt == DataType::QASYMM8_SIGNED; }, |
Sheri Zhang | 23adc4c | 2021-01-05 12:48:45 +0000 | [diff] [blame] | 114 | REGISTER_QASYMM8_SIGNED_NEON(arm_compute::cpu::qasymm8_signed_neon_scale) |
| 115 | }, |
| 116 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 117 | "neon_u8_scale", |
Gunes Bayir | 53929b1 | 2022-08-11 12:15:39 +0100 | [diff] [blame] | 118 | [](const ScaleKernelDataTypeISASelectorData & data) { return data.dt == DataType::U8; }, |
Gian Marco Iodice | 8b8405a | 2021-10-01 17:48:02 +0100 | [diff] [blame] | 119 | REGISTER_INTEGER_NEON(arm_compute::cpu::u8_neon_scale) |
Sheri Zhang | 23adc4c | 2021-01-05 12:48:45 +0000 | [diff] [blame] | 120 | }, |
| 121 | { |
Gunes Bayir | c4f2743 | 2022-09-11 15:59:19 +0100 | [diff] [blame] | 122 | "neon_s8_scale", |
| 123 | [](const ScaleKernelDataTypeISASelectorData & data) { return data.dt == DataType::S8; }, |
| 124 | REGISTER_INTEGER_NEON(arm_compute::cpu::s8_neon_scale) |
| 125 | }, |
| 126 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 127 | "neon_s16_scale", |
Gunes Bayir | 53929b1 | 2022-08-11 12:15:39 +0100 | [diff] [blame] | 128 | [](const ScaleKernelDataTypeISASelectorData & data) { return data.dt == DataType::S16; }, |
Gian Marco Iodice | 8b8405a | 2021-10-01 17:48:02 +0100 | [diff] [blame] | 129 | REGISTER_INTEGER_NEON(arm_compute::cpu::s16_neon_scale) |
Sheri Zhang | 23adc4c | 2021-01-05 12:48:45 +0000 | [diff] [blame] | 130 | }, |
Sheri Zhang | 23adc4c | 2021-01-05 12:48:45 +0000 | [diff] [blame] | 131 | }; |
| 132 | |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 133 | Status validate_arguments(const ITensorInfo *src, const ITensorInfo *dx, const ITensorInfo *dy, |
| 134 | const ITensorInfo *offsets, ITensorInfo *dst, const ScaleKernelInfo &info) |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 135 | { |
Gunes Bayir | 53929b1 | 2022-08-11 12:15:39 +0100 | [diff] [blame] | 136 | const auto *uk = CpuScaleKernel::get_implementation(ScaleKernelDataTypeISASelectorData{ src->data_type(), CPUInfo::get().get_isa(), info.interpolation_policy }); |
Giorgio Arena | 5ae8d80 | 2021-11-18 18:02:13 +0000 | [diff] [blame] | 137 | |
Sheri Zhang | 23adc4c | 2021-01-05 12:48:45 +0000 | [diff] [blame] | 138 | ARM_COMPUTE_RETURN_ERROR_ON(uk == nullptr || uk->ukernel == nullptr); |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 139 | ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(dst); |
| 140 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(src, dst); |
| 141 | ARM_COMPUTE_RETURN_ERROR_ON(dst == src); |
Pablo Marquez Tello | 48c0ed9 | 2023-05-05 15:02:32 +0100 | [diff] [blame] | 142 | ARM_COMPUTE_RETURN_ERROR_ON(src->num_channels()!=1); |
Sang-Hoon Park | c261798 | 2020-05-20 22:13:47 +0100 | [diff] [blame] | 143 | ARM_COMPUTE_RETURN_ERROR_ON(info.sampling_policy != SamplingPolicy::CENTER && info.sampling_policy != SamplingPolicy::TOP_LEFT); |
Sang-Hoon Park | c261798 | 2020-05-20 22:13:47 +0100 | [diff] [blame] | 144 | ARM_COMPUTE_UNUSED(info.constant_border_value); |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 145 | ARM_COMPUTE_RETURN_ERROR_ON_MSG(info.use_padding, "Padding is not supported"); |
Georgios Pinitas | 20b4313 | 2018-05-14 16:05:23 +0100 | [diff] [blame] | 146 | |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 147 | const DataLayout data_layout = info.data_layout == DataLayout::UNKNOWN ? src->data_layout() : info.data_layout; |
Sang-Hoon Park | bb123bd | 2020-01-03 10:57:30 +0000 | [diff] [blame] | 148 | const auto width_index = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH); |
| 149 | const auto height_index = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT); |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 150 | const auto output_width = dst->dimension(width_index); |
| 151 | const auto output_height = dst->dimension(height_index); |
Sang-Hoon Park | bb123bd | 2020-01-03 10:57:30 +0000 | [diff] [blame] | 152 | ARM_COMPUTE_RETURN_ERROR_ON(output_width == 0); |
| 153 | ARM_COMPUTE_RETURN_ERROR_ON(output_height == 0); |
Georgios Pinitas | 20b4313 | 2018-05-14 16:05:23 +0100 | [diff] [blame] | 154 | |
Gunes Bayir | c4f2743 | 2022-09-11 15:59:19 +0100 | [diff] [blame] | 155 | ARM_COMPUTE_RETURN_ERROR_ON((src->data_type() == DataType::S8) && (data_layout != DataLayout::NHWC || info.interpolation_policy != InterpolationPolicy::BILINEAR |
| 156 | || info.border_mode != BorderMode::REPLICATE)); |
| 157 | |
Gunes Bayir | 0eed305 | 2022-09-04 21:00:10 +0100 | [diff] [blame] | 158 | if(info.interpolation_policy == InterpolationPolicy::NEAREST_NEIGHBOR && offsets != nullptr) |
Georgios Pinitas | 20b4313 | 2018-05-14 16:05:23 +0100 | [diff] [blame] | 159 | { |
| 160 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(offsets, 1, DataType::S32); |
| 161 | } |
| 162 | |
Gunes Bayir | 0eed305 | 2022-09-04 21:00:10 +0100 | [diff] [blame] | 163 | if(info.interpolation_policy == InterpolationPolicy::BILINEAR && offsets != nullptr) |
Georgios Pinitas | 20b4313 | 2018-05-14 16:05:23 +0100 | [diff] [blame] | 164 | { |
| 165 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(offsets, 1, DataType::S32); |
Michalis Spyrou | 7f8caf7 | 2021-05-13 13:35:30 +0100 | [diff] [blame] | 166 | if(dx != nullptr && dy != nullptr) |
| 167 | { |
| 168 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(dx, 1, DataType::F32); |
| 169 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(dy, 1, DataType::F32); |
| 170 | } |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame] | 171 | } |
Sang-Hoon Park | bb123bd | 2020-01-03 10:57:30 +0000 | [diff] [blame] | 172 | |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 173 | ARM_COMPUTE_RETURN_ERROR_ON(info.align_corners && !scale_utils::is_align_corners_allowed_sampling_policy(info.sampling_policy)); |
Georgios Pinitas | 20b4313 | 2018-05-14 16:05:23 +0100 | [diff] [blame] | 174 | |
Sang-Hoon Park | c261798 | 2020-05-20 22:13:47 +0100 | [diff] [blame] | 175 | if(info.interpolation_policy == InterpolationPolicy::AREA) |
Georgios Pinitas | 20b4313 | 2018-05-14 16:05:23 +0100 | [diff] [blame] | 176 | { |
| 177 | ARM_COMPUTE_RETURN_ERROR_ON(data_layout != DataLayout::NCHW); |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 178 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(src, 1, DataType::U8); |
Georgios Pinitas | 20b4313 | 2018-05-14 16:05:23 +0100 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | return Status{}; |
| 182 | } |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 183 | } // namespace |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 184 | |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 185 | void CpuScaleKernel::configure(const ITensorInfo *src, const ITensorInfo *dx, const ITensorInfo *dy, const ITensorInfo *offsets, |
| 186 | ITensorInfo *dst, const ScaleKernelInfo &info) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 187 | { |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 188 | ARM_COMPUTE_UNUSED(dx, dy, offsets); |
| 189 | ARM_COMPUTE_ERROR_ON_NULLPTR(src, dst); |
Georgios Pinitas | 20b4313 | 2018-05-14 16:05:23 +0100 | [diff] [blame] | 190 | // Perform validation step |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 191 | ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(src, |
| 192 | dx, |
| 193 | dy, |
| 194 | offsets, |
| 195 | dst, |
Sang-Hoon Park | c261798 | 2020-05-20 22:13:47 +0100 | [diff] [blame] | 196 | info)); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 197 | |
Gunes Bayir | 53929b1 | 2022-08-11 12:15:39 +0100 | [diff] [blame] | 198 | const auto *uk = CpuScaleKernel::get_implementation(ScaleKernelDataTypeISASelectorData{ src->data_type(), CPUInfo::get().get_isa(), info.interpolation_policy }); |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 199 | ARM_COMPUTE_ERROR_ON_NULLPTR(uk); |
| 200 | |
| 201 | _run_method = uk->ukernel; |
| 202 | _name = std::string("CpuScaleKernel").append("/").append(uk->name).append("_").append(string_from_interpolation_policy(info.interpolation_policy)); |
| 203 | |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 204 | // Get data layout and width/height indices |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 205 | _data_layout = info.data_layout == DataLayout::UNKNOWN ? src->data_layout() : info.data_layout; |
Michele Di Giorgio | 655e8c6 | 2021-01-28 12:51:02 +0000 | [diff] [blame] | 206 | const int idx_width = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::WIDTH); |
| 207 | const int idx_height = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::HEIGHT); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 208 | |
Sang-Hoon Park | c261798 | 2020-05-20 22:13:47 +0100 | [diff] [blame] | 209 | _policy = info.interpolation_policy; |
Sang-Hoon Park | c261798 | 2020-05-20 22:13:47 +0100 | [diff] [blame] | 210 | _border_mode = info.border_mode; |
| 211 | _constant_border_value = info.constant_border_value; |
Michele Di Giorgio | 7a81d2a | 2020-07-30 14:52:16 +0100 | [diff] [blame] | 212 | _align_corners = info.align_corners; |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 213 | |
Sang-Hoon Park | c261798 | 2020-05-20 22:13:47 +0100 | [diff] [blame] | 214 | if(info.sampling_policy == SamplingPolicy::CENTER) |
Vidhya Sudhan Loganathan | 3ac2f3a | 2019-01-17 15:16:19 +0000 | [diff] [blame] | 215 | { |
| 216 | _sampling_offset = 0.5f; |
| 217 | } |
| 218 | |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 219 | // Compute the ratio between source width/height and destination width/height |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 220 | const auto wr = scale_utils::calculate_resize_ratio(src->dimension(idx_width), dst->dimension(idx_width), _align_corners); |
| 221 | const auto hr = scale_utils::calculate_resize_ratio(src->dimension(idx_height), dst->dimension(idx_height), _align_corners); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 222 | |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 223 | // Area interpolation behaves as Nearest Neighbour in case of up-sampling |
Sheri Zhang | 23adc4c | 2021-01-05 12:48:45 +0000 | [diff] [blame] | 224 | _policy = (_policy == InterpolationPolicy::AREA && wr <= 1.f && hr <= 1.f) ? InterpolationPolicy::NEAREST_NEIGHBOR : _policy; |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 225 | |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 226 | if(_border_mode == BorderMode::UNDEFINED) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 227 | { |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 228 | _border_mode = BorderMode::CONSTANT; |
| 229 | _constant_border_value = PixelValue(); |
| 230 | } |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 231 | |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 232 | #ifdef ENABLE_NCHW_KERNELS |
Sheri Zhang | 23adc4c | 2021-01-05 12:48:45 +0000 | [diff] [blame] | 233 | // Configure scale function to run |
Michele Di Giorgio | 655e8c6 | 2021-01-28 12:51:02 +0000 | [diff] [blame] | 234 | if(_data_layout == DataLayout::NCHW) |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 235 | { |
Sheri Zhang | 23adc4c | 2021-01-05 12:48:45 +0000 | [diff] [blame] | 236 | std::string function_to_call("scale_"); |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 237 | function_to_call += string_from_data_type(src->data_type()) + "_"; |
Michele Di Giorgio | 655e8c6 | 2021-01-28 12:51:02 +0000 | [diff] [blame] | 238 | function_to_call += string_from_data_layout(_data_layout) + "_"; |
Sheri Zhang | 23adc4c | 2021-01-05 12:48:45 +0000 | [diff] [blame] | 239 | function_to_call += string_from_interpolation_policy(_policy); |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 240 | |
Sheri Zhang | 23adc4c | 2021-01-05 12:48:45 +0000 | [diff] [blame] | 241 | static std::map<std::string, ScaleFunctionPtr> map_function = |
| 242 | { |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 243 | { "scale_U8_NCHW_AREA_CONSTANT", &CpuScaleKernel::scale_area_nchw_u8 }, |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 244 | |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 245 | { "scale_U8_NCHW_BILINEAR", &CpuScaleKernel::scale_bilinear_nchw<uint8_t> }, |
| 246 | { "scale_U8_NCHW_NEAREST_NEIGHBOUR", &CpuScaleKernel::scale_nearest_nchw<uint8_t> }, |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 247 | |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 248 | { "scale_QASYMM8_NCHW_BILINEAR", &CpuScaleKernel::scale_bilinear_qasymm<uint8_t> }, |
| 249 | { "scale_QASYMM8_NCHW_NEAREST_NEIGHBOUR", &CpuScaleKernel::scale_nearest_nchw<uint8_t> }, |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 250 | |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 251 | { "scale_QASYMM8_SIGNED_NCHW_BILINEAR", &CpuScaleKernel::scale_bilinear_qasymm<int8_t> }, |
| 252 | { "scale_QASYMM8_SIGNED_NCHW_NEAREST_NEIGHBOUR", &CpuScaleKernel::scale_nearest_nchw<int8_t> }, |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 253 | |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 254 | { "scale_S16_NCHW_BILINEAR", &CpuScaleKernel::scale_bilinear_nchw<int16_t> }, |
| 255 | { "scale_S16_NCHW_NEAREST_NEIGHBOUR", &CpuScaleKernel::scale_nearest_nchw<int16_t> }, |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 256 | |
| 257 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 258 | { "scale_F16_NCHW_BILINEAR", &CpuScaleKernel::scale_bilinear_nchw<float16_t> }, |
| 259 | { "scale_F16_NCHW_NEAREST_NEIGHBOUR", &CpuScaleKernel::scale_nearest_nchw<float16_t> }, |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 260 | #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */ |
| 261 | |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 262 | { "scale_F32_NCHW_BILINEAR", &CpuScaleKernel::scale_bilinear_nchw<float> }, |
| 263 | { "scale_F32_NCHW_NEAREST_NEIGHBOUR", &CpuScaleKernel::scale_nearest_nchw<float> }, |
Sheri Zhang | 23adc4c | 2021-01-05 12:48:45 +0000 | [diff] [blame] | 264 | }; |
| 265 | auto it = map_function.find(function_to_call); |
| 266 | if(it != map_function.end()) |
| 267 | { |
| 268 | _func = it->second; |
| 269 | } |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 270 | } |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 271 | #endif // ENABLE_NCHW_KERNELS |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 272 | |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 273 | // Configure window |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 274 | Window win = calculate_max_window(*dst, Steps()); |
| 275 | ICpuKernel::configure(win); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 276 | } |
| 277 | |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 278 | #ifdef ENABLE_NCHW_KERNELS |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 279 | template <typename T> |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 280 | void CpuScaleKernel::scale_nearest_nchw(const ITensor *src, ITensor *dst, const ITensor *dx, const ITensor *dy, const ITensor *offsets, const Window &window) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 281 | { |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 282 | ARM_COMPUTE_UNUSED(dx, dy); |
| 283 | const size_t in_stride_x = src->info()->dimension(0) + src->info()->padding().left + src->info()->padding().right; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 284 | |
| 285 | // Compute the ratio between source height and destination height |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 286 | const auto hr = scale_utils::calculate_resize_ratio(src->info()->dimension(1), dst->info()->dimension(1), _align_corners); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 287 | |
| 288 | // Don't increment in X and Y direction for the input tensor |
| 289 | // A pointer to the start of this plane is needed as base for the precomputed offsets |
| 290 | Window win_in(window); |
| 291 | win_in.set(Window::DimX, Window::Dimension(0, 0, 0)); |
| 292 | win_in.set(Window::DimY, Window::Dimension(0, 0, 0)); |
| 293 | |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 294 | // Set offsets window |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 295 | Window win_off; |
| 296 | win_off.set(Window::DimX, window[Window::DimX]); |
| 297 | win_off.set(Window::DimY, window[Window::DimY]); |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 298 | for(size_t d = Window::DimZ; d < offsets->info()->num_dimensions(); ++d) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 299 | { |
| 300 | win_off.set(d, Window::Dimension(0, 0, 0)); |
| 301 | } |
| 302 | |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 303 | // Create iterators |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 304 | Iterator src_i(src, win_in); |
| 305 | Iterator dst_i(dst, window); |
| 306 | Iterator offsets_i(offsets, win_off); |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 307 | execute_window_loop(window, [&](const Coordinates & id) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 308 | { |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 309 | const auto offsets_ptr = reinterpret_cast<const int32_t *>(offsets_i.ptr()); |
| 310 | const auto in_yi = static_cast<int32_t>(_align_corners ? utils::rounding::round_half_away_from_zero((id.y() + _sampling_offset) * hr) : std::floor(( |
| 311 | id.y() + _sampling_offset) |
| 312 | * hr)); |
| 313 | const int32_t offset_row = in_yi * in_stride_x; |
| 314 | *reinterpret_cast<T *>(dst_i.ptr()) = *(reinterpret_cast<const T *>(src_i.ptr()) + offsets_ptr[0] + offset_row); |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 315 | }, |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 316 | src_i, offsets_i, dst_i); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 317 | } |
| 318 | |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 319 | template <typename T> |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 320 | void CpuScaleKernel::scale_bilinear_nchw(const ITensor *src, ITensor *dst, const ITensor *dx, const ITensor *dy, const ITensor *offsets, const Window &window) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 321 | { |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 322 | // Compute the ratio between source height and destination height |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 323 | const auto hr = scale_utils::calculate_resize_ratio(src->info()->dimension(1), dst->info()->dimension(1), _align_corners); |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 324 | Window win_off; |
| 325 | win_off.set(Window::DimX, window.x()); |
| 326 | win_off.set(Window::DimY, window.y()); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 327 | |
| 328 | // Don't increment in X and Y direction for the input tensor |
| 329 | // A pointer to the start of this plane is needed as base for the precomputed offsets |
| 330 | Window win_in(window); |
| 331 | win_in.set(Window::DimX, Window::Dimension(0, 0, 0)); |
| 332 | win_in.set(Window::DimY, Window::Dimension(0, 0, 0)); |
| 333 | |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 334 | for(size_t d = Window::DimZ; d < offsets->info()->num_dimensions(); ++d) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 335 | { |
| 336 | win_off.set(d, Window::Dimension(0, 0, 0)); |
| 337 | } |
| 338 | |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 339 | Iterator src_i(src, win_in); |
| 340 | Iterator dst_i(dst, window); |
| 341 | Iterator offsets_i(offsets, win_off); |
| 342 | Iterator dx_i(dx, win_off); |
| 343 | Iterator dy_i(dy, win_off); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 344 | |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 345 | const int32_t in_dim_w = src->info()->dimension(0); |
| 346 | const int32_t in_dim_h = src->info()->dimension(1); |
| 347 | const int32_t in_stride_w = in_dim_w + src->info()->padding().left + src->info()->padding().right; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 348 | |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 349 | if(_border_mode == BorderMode::CONSTANT) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 350 | { |
Georgios Pinitas | c47ef20 | 2018-11-16 18:19:43 +0000 | [diff] [blame] | 351 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 352 | using ConstType = typename std::conditional<std::is_same<T, float16_t>::value, half, T>::type; |
| 353 | #else /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */ |
| 354 | using ConstType = T; |
Georgios Pinitas | c47ef20 | 2018-11-16 18:19:43 +0000 | [diff] [blame] | 355 | #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */ |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 356 | const T const_border_value = static_cast<T>(_constant_border_value.get<ConstType>()); |
| 357 | execute_window_loop(window, [&](const Coordinates & id) |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 358 | { |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 359 | const int32_t index_h = std::floor((id.y() + _sampling_offset) * hr - _sampling_offset); |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 360 | const auto index_w = *(reinterpret_cast<const int32_t *>(offsets_i.ptr())); |
| 361 | const auto dx_val = *(reinterpret_cast<const float *>(dx_i.ptr())); |
| 362 | const auto dy_val = *(reinterpret_cast<const float *>(dy_i.ptr())); |
| 363 | const auto pixel_row_ptr = reinterpret_cast<const T *>(src_i.ptr()); |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 364 | |
Manuel Bottini | 4968285 | 2020-10-13 10:25:31 +0100 | [diff] [blame] | 365 | 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_stride_w)) : const_border_value; |
| 366 | 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_stride_w)) : const_border_value; |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 367 | const auto a10 = (0 <= index_w && index_w < in_dim_w && -1 <= index_h |
| 368 | && index_h < in_dim_h - 1) ? |
Manuel Bottini | 4968285 | 2020-10-13 10:25:31 +0100 | [diff] [blame] | 369 | (*(pixel_row_ptr + index_w + index_h * in_stride_w + in_stride_w)) : |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 370 | const_border_value; |
| 371 | const auto a11 = (-1 <= index_w && index_w < in_dim_w - 1 && -1 <= index_h |
| 372 | && index_h < in_dim_h - 1) ? |
Manuel Bottini | 4968285 | 2020-10-13 10:25:31 +0100 | [diff] [blame] | 373 | (*(pixel_row_ptr + index_w + 1 + index_h * in_stride_w + in_stride_w)) : |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 374 | const_border_value; |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 375 | |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 376 | *reinterpret_cast<T *>(dst_i.ptr()) = static_cast<T>(scale_helpers::delta_bilinear(a00, a01, a10, a11, dx_val, dy_val)); |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 377 | }, |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 378 | src_i, offsets_i, dx_i, dy_i, dst_i); |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 379 | } |
| 380 | else if(_border_mode == BorderMode::REPLICATE) |
| 381 | { |
| 382 | execute_window_loop(window, [&](const Coordinates & id) |
| 383 | { |
| 384 | const int index_h = std::floor((id.y() + _sampling_offset) * hr - _sampling_offset); |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 385 | const auto index_w = *(reinterpret_cast<const int32_t *>(offsets_i.ptr())); |
| 386 | const auto dx_val = *(reinterpret_cast<const float *>(dx_i.ptr())); |
| 387 | const auto dy_val = *(reinterpret_cast<const float *>(dy_i.ptr())); |
| 388 | const auto pixel_row_ptr = reinterpret_cast<const T *>(src_i.ptr()); |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 389 | |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 390 | auto clamped_x = utility::clamp<int>(index_w, 0, in_dim_w - 1); |
| 391 | auto clamped_x1 = utility::clamp<int>(index_w + 1, 0, in_dim_w - 1); |
| 392 | auto clamped_y = utility::clamp<int>(index_h, 0, in_dim_h - 1); |
| 393 | auto clamped_y1 = utility::clamp<int>(index_h + 1, 0, in_dim_h - 1); |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 394 | |
Manuel Bottini | 4968285 | 2020-10-13 10:25:31 +0100 | [diff] [blame] | 395 | const auto a00 = *(pixel_row_ptr + clamped_x + clamped_y * in_stride_w); |
| 396 | const auto a01 = *(pixel_row_ptr + clamped_x1 + clamped_y * in_stride_w); |
| 397 | const auto a10 = *(pixel_row_ptr + clamped_x + clamped_y1 * in_stride_w); |
| 398 | const auto a11 = *(pixel_row_ptr + clamped_x1 + clamped_y1 * in_stride_w); |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 399 | |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 400 | *reinterpret_cast<T *>(dst_i.ptr()) = static_cast<T>(scale_helpers::delta_bilinear(a00, a01, a10, a11, dx_val, dy_val)); |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 401 | }, |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 402 | src_i, offsets_i, dx_i, dy_i, dst_i); |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 403 | } |
| 404 | else |
| 405 | { |
| 406 | ARM_COMPUTE_ERROR("Not implemented"); |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 407 | } |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 408 | } |
| 409 | |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 410 | void CpuScaleKernel::scale_area_nchw_u8(const ITensor *src, ITensor *dst, const ITensor *dx, const ITensor *dy, const ITensor *offsets, const Window &window) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 411 | { |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 412 | ARM_COMPUTE_UNUSED(dx, dy, offsets); |
Sang-Hoon Park | 68dd25f | 2020-10-19 16:00:11 +0100 | [diff] [blame] | 413 | using namespace scale_helpers; |
| 414 | |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 415 | ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(src, 1, DataType::U8); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 416 | |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 417 | // Don't increment in width/height/channels for the input tensor |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 418 | // A pointer to the start of this plane is needed as base for the precomputed offsets |
| 419 | Window win_in(window); |
| 420 | win_in.set(Window::DimX, Window::Dimension(0, 0, 0)); |
| 421 | win_in.set(Window::DimY, Window::Dimension(0, 0, 0)); |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 422 | win_in.set(Window::DimZ, Window::Dimension(0, 0, 0)); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 423 | |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 424 | Iterator src_i(src, win_in); |
| 425 | Iterator dst_i(dst, window); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 426 | |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 427 | const auto wr = scale_utils::calculate_resize_ratio(src->info()->dimension(0), dst->info()->dimension(0), _align_corners); |
| 428 | const auto hr = scale_utils::calculate_resize_ratio(src->info()->dimension(1), dst->info()->dimension(1), _align_corners); |
| 429 | const auto w = src->info()->dimension(0); |
| 430 | const auto h = src->info()->dimension(1); |
| 431 | const size_t in_stride = src->info()->strides_in_bytes()[1]; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 432 | |
| 433 | execute_window_loop(window, [&](const Coordinates & id) |
| 434 | { |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 435 | const auto in_ptr = reinterpret_cast<const uint8_t *>(src_i.ptr()); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 436 | |
| 437 | uint8x8_t tmp0 = vdup_n_u8(0); |
| 438 | tmp0 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x(), id.y()), tmp0, 0); |
| 439 | tmp0 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 1, id.y()), tmp0, 1); |
| 440 | tmp0 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 2, id.y()), tmp0, 2); |
| 441 | tmp0 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 3, id.y()), tmp0, 3); |
| 442 | tmp0 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 4, id.y()), tmp0, 4); |
| 443 | tmp0 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 5, id.y()), tmp0, 5); |
| 444 | tmp0 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 6, id.y()), tmp0, 6); |
| 445 | tmp0 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 7, id.y()), tmp0, 7); |
| 446 | |
| 447 | uint8x8_t tmp1 = vdup_n_u8(0); |
| 448 | tmp1 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 8, id.y()), tmp1, 0); |
| 449 | tmp1 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 9, id.y()), tmp1, 1); |
| 450 | tmp1 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 10, id.y()), tmp1, 2); |
| 451 | tmp1 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 11, id.y()), tmp1, 3); |
| 452 | tmp1 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 12, id.y()), tmp1, 4); |
| 453 | tmp1 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 13, id.y()), tmp1, 5); |
| 454 | tmp1 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 14, id.y()), tmp1, 6); |
| 455 | tmp1 = vset_lane_u8(pixel_area_c1u8_clamp(in_ptr, in_stride, w, h, wr, hr, id.x() + 15, id.y()), tmp1, 7); |
| 456 | |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 457 | vst1q_u8(dst_i.ptr(), vcombine_u8(tmp0, tmp1)); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 458 | }, |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 459 | src_i, dst_i); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 460 | } |
| 461 | |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 462 | template <typename T> |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 463 | void CpuScaleKernel::scale_bilinear_qasymm(const ITensor *src, ITensor *dst, const ITensor *dx, const ITensor *dy, const ITensor *offsets, const Window &window) |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 464 | { |
| 465 | // Get data layout and width/height indices |
Michele Di Giorgio | 655e8c6 | 2021-01-28 12:51:02 +0000 | [diff] [blame] | 466 | const int idx_width = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::WIDTH); |
| 467 | const int idx_height = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::HEIGHT); |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 468 | |
| 469 | // Compute the ratio between source height and destination height |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 470 | const auto hr = scale_utils::calculate_resize_ratio(src->info()->dimension(idx_height), dst->info()->dimension(idx_height), _align_corners); |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 471 | Window win_off; |
| 472 | win_off.set(Window::DimX, Window::Dimension(0, 0, 0)); |
| 473 | win_off.set(Window::DimY, Window::Dimension(0, 0, 0)); |
| 474 | |
| 475 | // Don't increment in X and Y direction for the input tensor |
| 476 | // A pointer to the start of this plane is needed as base for the precomputed offsets |
| 477 | Window win_in(window); |
| 478 | win_in.set(idx_width, Window::Dimension(0, 0, 0)); |
| 479 | win_in.set(idx_height, Window::Dimension(0, 0, 0)); |
| 480 | |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 481 | for(size_t d = Window::DimZ; d < offsets->info()->num_dimensions(); ++d) |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 482 | { |
| 483 | win_off.set(d, Window::Dimension(0, 0, 0)); |
| 484 | } |
| 485 | |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 486 | Iterator src_i(src, win_in); |
| 487 | Iterator dst_i(dst, window); |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 488 | |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 489 | const int32_t in_dim_w = src->info()->dimension(idx_width); |
| 490 | const int32_t in_dim_h = src->info()->dimension(idx_height); |
| 491 | const int32_t stride_w = src->info()->strides_in_bytes()[idx_width]; |
| 492 | const int32_t stride_h = src->info()->strides_in_bytes()[idx_height]; |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 493 | |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 494 | const UniformQuantizationInfo iq_info = src->info()->quantization_info().uniform(); |
| 495 | const UniformQuantizationInfo oq_info = dst->info()->quantization_info().uniform(); |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 496 | |
| 497 | if(_border_mode == BorderMode::CONSTANT) |
| 498 | { |
| 499 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 500 | using ConstType = typename std::conditional<std::is_same<T, float16_t>::value, half, T>::type; |
| 501 | #else /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */ |
| 502 | using ConstType = T; |
| 503 | #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */ |
| 504 | const T const_border_value = static_cast<T>(_constant_border_value.get<ConstType>()); |
| 505 | execute_window_loop(window, [&](const Coordinates & id) |
| 506 | { |
| 507 | const int32_t index_h = std::floor((id[idx_height] + _sampling_offset) * hr - _sampling_offset); |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 508 | const int32_t index_w = *(reinterpret_cast<const int32_t *>(offsets->ptr_to_element(Coordinates(id[idx_width], id[idx_height])))); |
| 509 | const auto dx_val = *(reinterpret_cast<const float *>(dx->ptr_to_element(Coordinates(id[idx_width], id[idx_height])))); |
| 510 | const auto dy_val = *(reinterpret_cast<const float *>(dy->ptr_to_element(Coordinates(id[idx_width], id[idx_height])))); |
| 511 | const auto pixel_row_ptr = reinterpret_cast<const T *>(src_i.ptr()); |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 512 | |
| 513 | const auto a00 = (0 <= index_w && index_w < in_dim_w && 0 <= index_h && index_h < in_dim_h) ? |
| 514 | (*(pixel_row_ptr + index_w * stride_w + index_h * stride_h)) : |
| 515 | const_border_value; |
| 516 | const auto a01 = (-1 <= index_w && index_w < in_dim_w - 1 && 0 <= index_h && index_h < in_dim_h) ? |
| 517 | (*(pixel_row_ptr + (index_w + 1) * stride_w + index_h * stride_h)) : |
| 518 | const_border_value; |
| 519 | const auto a10 = (0 <= index_w && index_w < in_dim_w && -1 <= index_h && index_h < in_dim_h - 1) ? |
| 520 | (*(pixel_row_ptr + index_w * stride_w + (index_h + 1) * stride_h)) : |
| 521 | const_border_value; |
| 522 | const auto a11 = (-1 <= index_w && index_w < in_dim_w - 1 && -1 <= index_h && index_h < in_dim_h - 1) ? |
| 523 | (*(pixel_row_ptr + (index_w + 1) * stride_w + (index_h + 1) * stride_h)) : |
| 524 | const_border_value; |
| 525 | |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 526 | const float inp00 = Qasymm8QuantizationHelper<T>::dequantize(a00, iq_info); |
| 527 | const float inp01 = Qasymm8QuantizationHelper<T>::dequantize(a01, iq_info); |
| 528 | const float inp10 = Qasymm8QuantizationHelper<T>::dequantize(a10, iq_info); |
| 529 | const float inp11 = Qasymm8QuantizationHelper<T>::dequantize(a11, iq_info); |
| 530 | *reinterpret_cast<T *>(dst_i.ptr()) = Qasymm8QuantizationHelper<T>::quantize(scale_helpers::delta_bilinear(inp00, inp01, inp10, inp11, dx_val, dy_val), oq_info); |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 531 | }, |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 532 | src_i, dst_i); |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 533 | } |
| 534 | else if(_border_mode == BorderMode::REPLICATE) |
| 535 | { |
| 536 | execute_window_loop(window, [&](const Coordinates & id) |
| 537 | { |
| 538 | const int index_h = std::floor((id[idx_height] + _sampling_offset) * hr - _sampling_offset); |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 539 | const int32_t index_w = *(reinterpret_cast<const int32_t *>(offsets->ptr_to_element(Coordinates(id[idx_width], id[idx_height])))); |
| 540 | const auto dx_val = *(reinterpret_cast<const float *>(dx->ptr_to_element(Coordinates(id[idx_width], id[idx_height])))); |
| 541 | const auto dy_val = *(reinterpret_cast<const float *>(dy->ptr_to_element(Coordinates(id[idx_width], id[idx_height])))); |
| 542 | const auto pixel_row_ptr = reinterpret_cast<const T *>(src_i.ptr()); |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 543 | |
| 544 | auto clamped_w = utility::clamp<int>(index_w, 0, in_dim_w - 1); |
| 545 | auto clamped_w1 = utility::clamp<int>(index_w + 1, 0, in_dim_w - 1); |
| 546 | auto clamped_h = utility::clamp<int>(index_h, 0, in_dim_h - 1); |
| 547 | auto clamped_h1 = utility::clamp<int>(index_h + 1, 0, in_dim_h - 1); |
| 548 | |
| 549 | const auto a00 = *(pixel_row_ptr + clamped_w * stride_w + clamped_h * stride_h); |
| 550 | const auto a01 = *(pixel_row_ptr + clamped_w1 * stride_w + clamped_h * stride_h); |
| 551 | const auto a10 = *(pixel_row_ptr + clamped_w * stride_w + clamped_h1 * stride_h); |
| 552 | const auto a11 = *(pixel_row_ptr + clamped_w1 * stride_w + clamped_h1 * stride_h); |
| 553 | |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 554 | const float inp00 = Qasymm8QuantizationHelper<T>::dequantize(a00, iq_info); |
| 555 | const float inp01 = Qasymm8QuantizationHelper<T>::dequantize(a01, iq_info); |
| 556 | const float inp10 = Qasymm8QuantizationHelper<T>::dequantize(a10, iq_info); |
| 557 | const float inp11 = Qasymm8QuantizationHelper<T>::dequantize(a11, iq_info); |
| 558 | *reinterpret_cast<T *>(dst_i.ptr()) = Qasymm8QuantizationHelper<T>::quantize(scale_helpers::delta_bilinear(inp00, inp01, inp10, inp11, dx_val, dy_val), oq_info); |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 559 | }, |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 560 | src_i, dst_i); |
Manuel Bottini | fc2f6d0 | 2020-08-26 16:28:38 +0100 | [diff] [blame] | 561 | } |
| 562 | else |
| 563 | { |
| 564 | ARM_COMPUTE_ERROR("Not implemented"); |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 565 | } |
| 566 | } |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 567 | #endif // ENABLE_NCHW_KERNELS |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 568 | |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 569 | Status CpuScaleKernel::validate(const ITensorInfo *input, const ITensorInfo *dx, const ITensorInfo *dy, |
| 570 | const ITensorInfo *offsets, ITensorInfo *output, const ScaleKernelInfo &info) |
Georgios Pinitas | 20b4313 | 2018-05-14 16:05:23 +0100 | [diff] [blame] | 571 | { |
Sang-Hoon Park | c261798 | 2020-05-20 22:13:47 +0100 | [diff] [blame] | 572 | ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, dx, dy, offsets, output, info)); |
Georgios Pinitas | 20b4313 | 2018-05-14 16:05:23 +0100 | [diff] [blame] | 573 | return Status{}; |
| 574 | } |
| 575 | |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 576 | void CpuScaleKernel::run_op(ITensorPack &tensors, const Window &window, const ThreadInfo &info) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 577 | { |
Moritz Pflanzer | c186b57 | 2017-09-07 09:48:04 +0100 | [diff] [blame] | 578 | ARM_COMPUTE_UNUSED(info); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 579 | ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 580 | ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(ICpuKernel::window(), window); |
Michele Di Giorgio | 655e8c6 | 2021-01-28 12:51:02 +0000 | [diff] [blame] | 581 | ARM_COMPUTE_ERROR_ON(_func == nullptr && _data_layout == DataLayout::NCHW); |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 582 | ARM_COMPUTE_ERROR_ON(_run_method == nullptr && _data_layout == DataLayout::NHWC); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 583 | |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 584 | const auto src = tensors.get_const_tensor(TensorType::ACL_SRC); |
| 585 | auto dst = tensors.get_tensor(TensorType::ACL_DST); |
| 586 | const auto dx = tensors.get_const_tensor(TensorType::ACL_INT_0); |
| 587 | const auto dy = tensors.get_const_tensor(TensorType::ACL_INT_1); |
| 588 | const auto offsets = tensors.get_const_tensor(TensorType::ACL_INT_2); |
| 589 | |
Michele Di Giorgio | 655e8c6 | 2021-01-28 12:51:02 +0000 | [diff] [blame] | 590 | if(_data_layout == DataLayout::NCHW) |
Sheri Zhang | 23adc4c | 2021-01-05 12:48:45 +0000 | [diff] [blame] | 591 | { |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 592 | (this->*_func)(src, dst, dx, dy, offsets, window); |
Sheri Zhang | 23adc4c | 2021-01-05 12:48:45 +0000 | [diff] [blame] | 593 | } |
| 594 | else |
| 595 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 596 | _run_method(src, dst, offsets, dx, dy, _policy, _border_mode, _constant_border_value, _sampling_offset, _align_corners, window); |
Sheri Zhang | 23adc4c | 2021-01-05 12:48:45 +0000 | [diff] [blame] | 597 | } |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 598 | } |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 599 | |
| 600 | const char *CpuScaleKernel::name() const |
| 601 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 602 | return _name.c_str(); |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 603 | } |
Giorgio Arena | 5ae8d80 | 2021-11-18 18:02:13 +0000 | [diff] [blame] | 604 | |
| 605 | const std::vector<CpuScaleKernel::ScaleKernel> &CpuScaleKernel::get_available_kernels() |
| 606 | { |
| 607 | return available_kernels; |
| 608 | } |
| 609 | |
Manuel Bottini | 10b3826 | 2021-02-19 18:16:44 +0000 | [diff] [blame] | 610 | } // namespace kernels |
| 611 | } // namespace cpu |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 612 | } // namespace arm_compute |