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