giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 1 | /* |
Sang-Hoon Park | 5db75c3 | 2021-01-07 16:59:32 +0000 | [diff] [blame] | 2 | * Copyright (c) 2018-2021 Arm Limited. |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [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 | */ |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame] | 24 | #include "src/core/cpu/kernels/CpuElementwiseKernel.h" |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 25 | |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 26 | #include "arm_compute/core/Helpers.h" |
Sang-Hoon Park | 68dd25f | 2020-10-19 16:00:11 +0100 | [diff] [blame] | 27 | #include "src/core/CPP/Validate.h" |
Sang-Hoon Park | d2447bb | 2021-01-18 09:41:37 +0000 | [diff] [blame] | 28 | #include "src/core/common/Registrars.h" |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame] | 29 | #include "src/core/cpu/kernels/elementwise/neon/elementwise_list.h" |
| 30 | #include "src/core/cpu/kernels/elementwise/neon/elementwise_quantized_list.h" |
| 31 | #include "src/core/cpu/kernels/elementwise/sve/elementwise_list.h" |
| 32 | #include "src/core/cpu/kernels/elementwise/sve/elementwise_quantized_list.h" |
Sang-Hoon Park | 68dd25f | 2020-10-19 16:00:11 +0100 | [diff] [blame] | 33 | #include "src/core/helpers/AutoConfiguration.h" |
| 34 | #include "src/core/helpers/WindowHelpers.h" |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 35 | |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 36 | #include <arm_neon.h> |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 37 | |
| 38 | namespace arm_compute |
| 39 | { |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame] | 40 | namespace cpu |
| 41 | { |
| 42 | namespace kernels |
| 43 | { |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 44 | namespace |
| 45 | { |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 46 | struct ElementwiseSelectorData |
| 47 | { |
| 48 | DataType dt; |
| 49 | const CPUInfo &ci; |
| 50 | }; |
| 51 | |
| 52 | using ElementwiseSelector = std::add_pointer<bool(const ElementwiseSelectorData &)>::type; |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame] | 53 | using UKernelType = CpuElementwiseKernel::ElementwiseFunction; |
Sang-Hoon Park | d2447bb | 2021-01-18 09:41:37 +0000 | [diff] [blame] | 54 | struct ElementwiseKernel |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 55 | { |
Sang-Hoon Park | d2447bb | 2021-01-18 09:41:37 +0000 | [diff] [blame] | 56 | const char *name; |
| 57 | const ElementwiseSelector is_selected; |
| 58 | UKernelType *ukernel; |
| 59 | }; |
| 60 | |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 61 | template <ArithmeticOperation op> |
| 62 | CpuElementwiseKernel::UKernelInfo configure_arithm_func(const ITensorInfo *src0, const ITensorInfo *src1, ITensorInfo *dst) |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 63 | { |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 64 | ARM_COMPUTE_UNUSED(src1, dst); |
Sang-Hoon Park | d2447bb | 2021-01-18 09:41:37 +0000 | [diff] [blame] | 65 | static ElementwiseKernel kernels[] = |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 66 | { |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 67 | #if defined(ARM_COMPUTE_ENABLE_SVE) |
| 68 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 69 | "sve_fp32_elementwise", |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 70 | [](const ElementwiseSelectorData & data) { return data.dt == DataType::F32 && data.ci.has_sve(); }, |
| 71 | REGISTER_FP32_SVE((arm_compute::cpu::elementwise_arithmetic_op<op, float32_t>)) |
| 72 | }, |
| 73 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 74 | "sve_s32_elementwise", |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 75 | [](const ElementwiseSelectorData & data) { return data.dt == DataType::S32 && data.ci.has_sve(); }, |
| 76 | REGISTER_INTEGER_SVE((arm_compute::cpu::elementwise_arithmetic_op<op, int32_t>)) |
| 77 | }, |
| 78 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 79 | "sve_s16_elementwise", |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 80 | [](const ElementwiseSelectorData & data) { return data.dt == DataType::S16 && data.ci.has_sve(); }, |
| 81 | REGISTER_INTEGER_SVE((arm_compute::cpu::elementwise_arithmetic_op<op, int16_t>)) |
| 82 | }, |
| 83 | #endif /* defined(ARM_COMPUTE_ENABLE_SVE) */ |
| 84 | #if defined(ARM_COMPUTE_ENABLE_NEON) |
| 85 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 86 | "neon_fp32_elementwise", |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 87 | [](const ElementwiseSelectorData & data) { return data.dt == DataType::F32; }, |
| 88 | REGISTER_FP32_NEON((arm_compute::cpu::elementwise_arithm_op<op, typename wrapper::traits::neon_vector<float, 4>>)) |
| 89 | }, |
| 90 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 91 | "neon_s32_elementwise", |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 92 | [](const ElementwiseSelectorData & data) { return data.dt == DataType::S32; }, |
| 93 | REGISTER_INTEGER_NEON((arm_compute::cpu::elementwise_arithm_op<op, typename wrapper::traits::neon_vector<int32_t, 4>>)) |
| 94 | }, |
| 95 | #endif /* defined(ARM_COMPUTE_ENABLE_NEON) */ |
| 96 | #if defined(ARM_COMPUTE_ENABLE_SVE2) |
| 97 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 98 | "sve2_qu8_elementwise", |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 99 | [](const ElementwiseSelectorData & data) { return data.dt == DataType::QASYMM8 && data.ci.has_sve2(); }, |
| 100 | REGISTER_QASYMM8_SVE((arm_compute::cpu::elementwise_arithmetic_quantized_op<op, uint8_t>)) |
| 101 | }, |
| 102 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 103 | "sve2_qs8_elementwise", |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 104 | [](const ElementwiseSelectorData & data) { return data.dt == DataType::QASYMM8_SIGNED && data.ci.has_sve2(); }, |
| 105 | REGISTER_QASYMM8_SIGNED_SVE((arm_compute::cpu::elementwise_arithmetic_quantized_op<op, int8_t>)) |
| 106 | }, |
| 107 | #endif /* defined(ARM_COMPUTE_ENABLE_SVE2) */ |
| 108 | #if defined(ARM_COMPUTE_ENABLE_NEON) || defined(ARM_COMPUTE_ENABLE_SVE) |
| 109 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 110 | "neon_qu8_elementwise", |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 111 | [](const ElementwiseSelectorData & data) { return data.dt == DataType::QASYMM8; }, |
| 112 | REGISTER_QASYMM8_NEON((arm_compute::cpu::elementwise_arithm_op_quantized<op>)) |
| 113 | }, |
| 114 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 115 | "neon_qs8_elementwise", |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 116 | [](const ElementwiseSelectorData & data) { return data.dt == DataType::QASYMM8_SIGNED; }, |
| 117 | REGISTER_QASYMM8_SIGNED_NEON((arm_compute::cpu::elementwise_arithm_op_quantized_signed<op>)) |
| 118 | }, |
| 119 | #endif /* defined(ARM_COMPUTE_ENABLE_NEON) || defined(ARM_COMPUTE_ENABLE_SVE) */ |
| 120 | #if defined(ARM_COMPUTE_ENABLE_SVE) |
| 121 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 122 | "sve_fp16_elementwise", |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 123 | [](const ElementwiseSelectorData & data) { return data.dt == DataType::F16 && data.ci.has_sve(); }, |
| 124 | REGISTER_FP16_SVE((arm_compute::cpu::elementwise_arithmetic_op<op, float16_t>)) |
| 125 | }, |
| 126 | #endif /* defined(ARM_COMPUTE_ENABLE_SVE) */ |
| 127 | #if defined(ARM_COMPUTE_ENABLE_NEON) |
Georgios Pinitas | bdcdc39 | 2021-04-22 16:42:03 +0100 | [diff] [blame] | 128 | #if defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 129 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 130 | "neon_fp16_elementwise", |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 131 | [](const ElementwiseSelectorData & data) { return data.dt == DataType::F16 && data.ci.has_fp16(); }, |
| 132 | REGISTER_FP16_NEON((arm_compute::cpu::elementwise_arithm_op<op, typename wrapper::traits::neon_vector<float16_t, 8>>)) |
| 133 | }, |
Georgios Pinitas | bdcdc39 | 2021-04-22 16:42:03 +0100 | [diff] [blame] | 134 | #endif /* defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) */ |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 135 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 136 | "neon_s16_elementwise", |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 137 | [](const ElementwiseSelectorData & data) { return data.dt == DataType::S16; }, |
| 138 | REGISTER_INTEGER_NEON((arm_compute::cpu::elementwise_arithm_op<op, typename wrapper::traits::neon_vector<int16_t, 8>>)) |
| 139 | }, |
| 140 | #endif /* defined(ARM_COMPUTE_ENABLE_NEON) */ |
Sang-Hoon Park | d2447bb | 2021-01-18 09:41:37 +0000 | [diff] [blame] | 141 | }; |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 142 | |
Sang-Hoon Park | d2447bb | 2021-01-18 09:41:37 +0000 | [diff] [blame] | 143 | for(const auto &uk : kernels) |
| 144 | { |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 145 | if(uk.is_selected({ src0->data_type(), CPUInfo::get() })) |
Sang-Hoon Park | d2447bb | 2021-01-18 09:41:37 +0000 | [diff] [blame] | 146 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 147 | return { uk.name, uk.ukernel }; |
Sang-Hoon Park | d2447bb | 2021-01-18 09:41:37 +0000 | [diff] [blame] | 148 | } |
| 149 | } |
| 150 | |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 151 | return { "", nullptr }; |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 152 | } |
| 153 | |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 154 | template <ComparisonOperation op> |
| 155 | CpuElementwiseKernel::UKernelInfo configure_comp_func(const ITensorInfo *src0, const ITensorInfo *src1, ITensorInfo *dst) |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 156 | { |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 157 | ARM_COMPUTE_UNUSED(src1, dst); |
Sang-Hoon Park | d2447bb | 2021-01-18 09:41:37 +0000 | [diff] [blame] | 158 | static ElementwiseKernel kernels[] = |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 159 | { |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 160 | #if defined(ARM_COMPUTE_ENABLE_SVE) |
| 161 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 162 | "sve_u8_comparison", |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 163 | [](const ElementwiseSelectorData & data) { return data.dt == DataType::U8 && data.ci.has_sve(); }, |
| 164 | REGISTER_INTEGER_SVE((arm_compute::cpu::elementwise_comparison_op<op, uint8_t>)) |
| 165 | }, |
| 166 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 167 | "sve_fp32_comparison", |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 168 | [](const ElementwiseSelectorData & data) { return data.dt == DataType::F32 && data.ci.has_sve(); }, |
| 169 | REGISTER_FP32_SVE((arm_compute::cpu::elementwise_comparison_op<op, float>)) |
| 170 | }, |
| 171 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 172 | "sve_s16_comparison", |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 173 | [](const ElementwiseSelectorData & data) { return data.dt == DataType::S16 && data.ci.has_sve(); }, |
| 174 | REGISTER_INTEGER_SVE((arm_compute::cpu::elementwise_comparison_op<op, int16_t>)) |
| 175 | }, |
| 176 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 177 | "sve_s32_comparison", |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 178 | [](const ElementwiseSelectorData & data) { return data.dt == DataType::S32 && data.ci.has_sve(); }, |
| 179 | REGISTER_INTEGER_SVE((arm_compute::cpu::elementwise_comparison_op<op, int32_t>)) |
| 180 | }, |
| 181 | #endif /* defined(ARM_COMPUTE_ENABLE_SVE) */ |
| 182 | #if defined(ARM_COMPUTE_ENABLE_NEON) |
| 183 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 184 | "neon_u8_comparison", |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 185 | [](const ElementwiseSelectorData & data) { return data.dt == DataType::U8; }, |
| 186 | REGISTER_INTEGER_NEON((arm_compute::cpu::elementwise_comp_op_8<op, uint8_t, uint8x16_t>)) |
| 187 | }, |
| 188 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 189 | "neon_fp32_comparison", |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 190 | [](const ElementwiseSelectorData & data) { return data.dt == DataType::F32; }, |
| 191 | REGISTER_FP32_NEON((arm_compute::cpu::elementwise_comp_op_32<op, float, float32x4_t>)) |
| 192 | }, |
| 193 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 194 | "neon_s16_comparison", |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 195 | [](const ElementwiseSelectorData & data) { return data.dt == DataType::S16; }, |
| 196 | REGISTER_INTEGER_NEON((arm_compute::cpu::elementwise_comp_op_16<op, int16_t, int16x8_t>)) |
| 197 | }, |
| 198 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 199 | "neon_s32_comparison", |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 200 | [](const ElementwiseSelectorData & data) { return data.dt == DataType::S32; }, |
| 201 | REGISTER_INTEGER_NEON((arm_compute::cpu::elementwise_comp_op_32<op, int32_t, int32x4_t>)) |
| 202 | }, |
| 203 | #endif /* defined(ARM_COMPUTE_ENABLE_NEON) */ |
| 204 | #if defined(ARM_COMPUTE_ENABLE_SVE2) |
| 205 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 206 | "sve2_qu8_comparison", |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 207 | [](const ElementwiseSelectorData & data) { return data.dt == DataType::QASYMM8 && data.ci.has_sve2(); }, |
| 208 | REGISTER_QASYMM8_SVE((arm_compute::cpu::elementwise_comparison_quantized_op<op, uint8_t>)) |
| 209 | }, |
| 210 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 211 | "sve2_qs8_comparison", |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 212 | [](const ElementwiseSelectorData & data) { return data.dt == DataType::QASYMM8_SIGNED && data.ci.has_sve2(); }, |
| 213 | REGISTER_QASYMM8_SIGNED_SVE((arm_compute::cpu::elementwise_comparison_quantized_op<op, int8_t>)) |
| 214 | }, |
| 215 | #endif /* defined(ARM_COMPUTE_ENABLE_SVE2) */ |
| 216 | #if defined(ARM_COMPUTE_ENABLE_NEON) || defined(ARM_COMPUTE_ENABLE_SVE) |
| 217 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 218 | "neon_qu8_comparison", |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 219 | [](const ElementwiseSelectorData & data) { return data.dt == DataType::QASYMM8; }, |
| 220 | REGISTER_QASYMM8_NEON((arm_compute::cpu::elementwise_comp_op_quantized<op>)) |
| 221 | }, |
| 222 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 223 | "neon_qs8_comparison", |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 224 | [](const ElementwiseSelectorData & data) { return data.dt == DataType::QASYMM8_SIGNED; }, |
| 225 | REGISTER_QASYMM8_SIGNED_NEON((arm_compute::cpu::elementwise_comp_op_quantized_signed<op>)) |
| 226 | }, |
| 227 | #endif /* defined(ARM_COMPUTE_ENABLE_NEON) || defined(ARM_COMPUTE_ENABLE_SVE) */ |
| 228 | #if defined(ARM_COMPUTE_ENABLE_SVE) |
| 229 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 230 | "sve_fp16_comparison", |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 231 | [](const ElementwiseSelectorData & data) { return data.dt == DataType::F16 && data.ci.has_sve(); }, |
| 232 | REGISTER_FP16_SVE((arm_compute::cpu::elementwise_comparison_op<op, float16_t>)) |
| 233 | }, |
| 234 | #endif /* defined(ARM_COMPUTE_ENABLE_SVE) */ |
| 235 | #if defined(ARM_COMPUTE_ENABLE_NEON) && defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) |
| 236 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 237 | "neon_fp16_comparison", |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 238 | [](const ElementwiseSelectorData & data) { return data.dt == DataType::F16 && data.ci.has_fp16(); }, |
| 239 | REGISTER_FP16_NEON((arm_compute::cpu::elementwise_comp_op_16<op, float16_t, float16x8_t>)) |
| 240 | }, |
| 241 | #endif /* defined(ARM_COMPUTE_ENABLE_NEON) && defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) */ |
Sang-Hoon Park | d2447bb | 2021-01-18 09:41:37 +0000 | [diff] [blame] | 242 | }; |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 243 | |
Sang-Hoon Park | d2447bb | 2021-01-18 09:41:37 +0000 | [diff] [blame] | 244 | for(const auto &uk : kernels) |
| 245 | { |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 246 | if(uk.is_selected({ src0->data_type(), CPUInfo::get() })) |
Sang-Hoon Park | d2447bb | 2021-01-18 09:41:37 +0000 | [diff] [blame] | 247 | { |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 248 | return { uk.name, uk.ukernel }; |
Sang-Hoon Park | d2447bb | 2021-01-18 09:41:37 +0000 | [diff] [blame] | 249 | } |
| 250 | } |
| 251 | |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 252 | return { "", nullptr }; |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 253 | } |
| 254 | } // namespace |
| 255 | |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 256 | Status CpuElementwiseKernel::validate_arguments_common(const ITensorInfo &src0, const ITensorInfo &src1, const ITensorInfo &dst) |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 257 | { |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 258 | ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(&src0); |
| 259 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(&src0, &src1); |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 260 | |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 261 | const TensorShape out_shape = TensorShape::broadcast_shape(src0.tensor_shape(), src1.tensor_shape()); |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 262 | |
| 263 | ARM_COMPUTE_RETURN_ERROR_ON_MSG(out_shape.total_size() == 0, "Inputs are not broadcast compatible"); |
| 264 | |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 265 | // Validate in case of configured dst |
| 266 | if(dst.total_size() > 0) |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 267 | { |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 268 | ARM_COMPUTE_RETURN_ERROR_ON_MSG(detail::have_different_dimensions(out_shape, dst.tensor_shape(), 0), |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 269 | "Wrong shape for output"); |
| 270 | } |
| 271 | |
| 272 | return Status{}; |
| 273 | } |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 274 | |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 275 | void CpuElementwiseKernel::configure_common(const ITensorInfo *src0, const ITensorInfo *src1, ITensorInfo *dst) |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 276 | { |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 277 | ARM_COMPUTE_ERROR_ON_NULLPTR(src0, src1, dst); |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 278 | |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 279 | const auto uk = get_implementation(src0, src1, dst); |
| 280 | |
| 281 | _run_method = uk.ukernel; |
| 282 | _name = std::string("CpuElementwiseKernel").append("/").append(uk.name); |
| 283 | |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 284 | // If any of shapes is dynamic, expect a configured window and dst at run-time. |
| 285 | if(src0->is_dynamic() || src1->is_dynamic()) |
| 286 | { |
| 287 | return; |
| 288 | } |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 289 | |
Sang-Hoon Park | d0b7b4b | 2021-03-09 10:47:30 +0000 | [diff] [blame] | 290 | auto shape_and_window = compute_output_shape_and_window(src0->tensor_shape(), src1->tensor_shape()); |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 291 | auto_init_if_empty(*dst, shape_and_window.first, 1, src0->data_type()); |
| 292 | ICpuKernel::configure(shape_and_window.second); |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 293 | } |
| 294 | |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame] | 295 | void CpuElementwiseKernel::run_op(ITensorPack &tensors, const Window &window, const ThreadInfo &info) |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 296 | { |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 297 | ARM_COMPUTE_UNUSED(info); |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 298 | ARM_COMPUTE_ERROR_ON(_run_method == nullptr); |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame] | 299 | |
| 300 | auto src0 = tensors.get_const_tensor(TensorType::ACL_SRC_0); |
| 301 | auto src1 = tensors.get_const_tensor(TensorType::ACL_SRC_1); |
| 302 | auto dst = tensors.get_tensor(TensorType::ACL_DST); |
| 303 | |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 304 | _run_method(src0, src1, dst, window); |
| 305 | } |
| 306 | |
| 307 | const char *CpuElementwiseKernel::name() const |
| 308 | { |
| 309 | return _name.c_str(); |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 310 | } |
| 311 | |
| 312 | /** Arithmetic operators (min, max, squared_diff) */ |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 313 | void CpuArithmeticKernel::configure(ArithmeticOperation op, const ITensorInfo *src0, const ITensorInfo *src1, ITensorInfo *dst) |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 314 | { |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 315 | ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(*src0, *src1, *dst)); |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame] | 316 | _op = op; |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 317 | configure_common(src0, src1, dst); |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 318 | } |
| 319 | |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 320 | Status CpuArithmeticKernel::validate_arguments(const ITensorInfo &src0, const ITensorInfo &src1, const ITensorInfo &dst) |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 321 | { |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 322 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(&src0, 1, DataType::QASYMM8, DataType::QASYMM8_SIGNED, DataType::S16, DataType::F16, DataType::S32, DataType::F32); |
| 323 | // Validate in case of configured dst |
| 324 | if(dst.total_size() > 0) |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 325 | { |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 326 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(&src0, &dst); |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 327 | } |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 328 | return validate_arguments_common(src0, src1, dst); |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 329 | } |
| 330 | |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 331 | Status CpuArithmeticKernel::validate(ArithmeticOperation op, const ITensorInfo *src0, const ITensorInfo *src1, const ITensorInfo *dst) |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 332 | { |
| 333 | ARM_COMPUTE_UNUSED(op); |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 334 | ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(src0, src1, dst); |
| 335 | ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(*src0, *src1, *dst)); |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 336 | return Status{}; |
| 337 | } |
| 338 | |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 339 | CpuElementwiseKernel::UKernelInfo CpuArithmeticKernel::get_implementation(const ITensorInfo *src0, const ITensorInfo *src1, ITensorInfo *dst) |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame] | 340 | { |
| 341 | switch(_op) |
| 342 | { |
| 343 | case ArithmeticOperation::MAX: |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 344 | return configure_arithm_func<ArithmeticOperation::MAX>(src0, src1, dst); |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame] | 345 | case ArithmeticOperation::MIN: |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 346 | return configure_arithm_func<ArithmeticOperation::MIN>(src0, src1, dst); |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame] | 347 | case ArithmeticOperation::SQUARED_DIFF: |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 348 | return configure_arithm_func<ArithmeticOperation::SQUARED_DIFF>(src0, src1, dst); |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame] | 349 | case ArithmeticOperation::PRELU: |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 350 | return configure_arithm_func<ArithmeticOperation::PRELU>(src0, src1, dst); |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame] | 351 | case ArithmeticOperation::DIV: |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 352 | return configure_arithm_func<ArithmeticOperation::DIV>(src0, src1, dst); |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame] | 353 | case ArithmeticOperation::POWER: |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 354 | return configure_arithm_func<ArithmeticOperation::POWER>(src0, src1, dst); |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame] | 355 | default: |
| 356 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 357 | } |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 358 | return { "", nullptr }; |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame] | 359 | } |
| 360 | |
George Wort | a1e7e28 | 2019-01-15 11:00:29 +0000 | [diff] [blame] | 361 | /** The division operator */ |
| 362 | |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 363 | void CpuDivisionKernel::configure(const ITensorInfo *src0, const ITensorInfo *src1, ITensorInfo *dst) |
George Wort | a1e7e28 | 2019-01-15 11:00:29 +0000 | [diff] [blame] | 364 | { |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 365 | ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(*src0, *src1, *dst)); |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame] | 366 | _op = ArithmeticOperation::DIV; |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 367 | configure_common(src0, src1, dst); |
George Wort | a1e7e28 | 2019-01-15 11:00:29 +0000 | [diff] [blame] | 368 | } |
| 369 | |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 370 | Status CpuDivisionKernel::validate_arguments(const ITensorInfo &src0, const ITensorInfo &src1, const ITensorInfo &dst) |
George Wort | a1e7e28 | 2019-01-15 11:00:29 +0000 | [diff] [blame] | 371 | { |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 372 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(&src0, 1, DataType::S32, DataType::F16, DataType::F32); |
| 373 | return CpuArithmeticKernel::validate_arguments(src0, src1, dst); |
George Wort | a1e7e28 | 2019-01-15 11:00:29 +0000 | [diff] [blame] | 374 | } |
| 375 | |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 376 | Status CpuDivisionKernel::validate(const ITensorInfo *src0, const ITensorInfo *src1, const ITensorInfo *dst) |
George Wort | a1e7e28 | 2019-01-15 11:00:29 +0000 | [diff] [blame] | 377 | { |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 378 | ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(src0, src1, dst); |
| 379 | ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(*src0, *src1, *dst)); |
George Wort | a1e7e28 | 2019-01-15 11:00:29 +0000 | [diff] [blame] | 380 | return Status{}; |
| 381 | } |
| 382 | |
Usama Arif | 81e671e | 2019-05-13 13:33:14 +0100 | [diff] [blame] | 383 | /** The power operator */ |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 384 | void CpuPowerKernel::configure(const ITensorInfo *src0, const ITensorInfo *src1, ITensorInfo *dst) |
Usama Arif | 81e671e | 2019-05-13 13:33:14 +0100 | [diff] [blame] | 385 | { |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 386 | ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(*src0, *src1, *dst)); |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame] | 387 | _op = ArithmeticOperation::POWER; |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 388 | configure_common(src0, src1, dst); |
Usama Arif | 81e671e | 2019-05-13 13:33:14 +0100 | [diff] [blame] | 389 | } |
| 390 | |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 391 | Status CpuPowerKernel::validate_arguments(const ITensorInfo &src0, const ITensorInfo &src1, const ITensorInfo &dst) |
Usama Arif | 81e671e | 2019-05-13 13:33:14 +0100 | [diff] [blame] | 392 | { |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 393 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(&src0, 1, DataType::F16, DataType::F32); |
| 394 | return CpuArithmeticKernel::validate_arguments(src0, src1, dst); |
Usama Arif | 81e671e | 2019-05-13 13:33:14 +0100 | [diff] [blame] | 395 | } |
| 396 | |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 397 | Status CpuPowerKernel::validate(const ITensorInfo *src0, const ITensorInfo *src1, const ITensorInfo *dst) |
Usama Arif | 81e671e | 2019-05-13 13:33:14 +0100 | [diff] [blame] | 398 | { |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 399 | ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(src0, src1, dst); |
| 400 | ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(*src0, *src1, *dst)); |
Usama Arif | 81e671e | 2019-05-13 13:33:14 +0100 | [diff] [blame] | 401 | return Status{}; |
| 402 | } |
| 403 | |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 404 | /** Comparison operators (equal, not equal, less than, greater than, less than or equal, greater than or equal) */ |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 405 | void CpuComparisonKernel::configure(ComparisonOperation op, const ITensorInfo *src0, const ITensorInfo *src1, ITensorInfo *dst) |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 406 | { |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 407 | ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(*src0, *src1, *dst)); |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame] | 408 | _op = op; |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 409 | configure_common(src0, src1, dst); |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 410 | } |
| 411 | |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 412 | Status CpuComparisonKernel::validate_arguments(const ITensorInfo &src0, const ITensorInfo &src1, const ITensorInfo &dst) |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 413 | { |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 414 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(&src0, 1, DataType::U8, DataType::QASYMM8, DataType::QASYMM8_SIGNED, DataType::S16, DataType::F16, DataType::S32, DataType::F32); |
| 415 | // Validate in case of configured dst |
| 416 | if(dst.total_size() > 0) |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 417 | { |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 418 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(&dst, 1, DataType::U8); |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 419 | } |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 420 | return validate_arguments_common(src0, src1, dst); |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 421 | } |
| 422 | |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 423 | Status CpuComparisonKernel::validate(ComparisonOperation op, const ITensorInfo *src0, const ITensorInfo *src1, const ITensorInfo *dst) |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 424 | { |
| 425 | ARM_COMPUTE_UNUSED(op); |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 426 | ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(src0, src1, dst); |
| 427 | ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(*src0, *src1, *dst)); |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 428 | return Status{}; |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 429 | } |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame] | 430 | |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 431 | CpuElementwiseKernel::UKernelInfo CpuComparisonKernel::get_implementation(const ITensorInfo *src0, const ITensorInfo *src1, ITensorInfo *dst) |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame] | 432 | { |
| 433 | switch(_op) |
| 434 | { |
| 435 | case ComparisonOperation::Equal: |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 436 | return configure_comp_func<ComparisonOperation::Equal>(src0, src1, dst); |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame] | 437 | case ComparisonOperation::NotEqual: |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 438 | return configure_comp_func<ComparisonOperation::NotEqual>(src0, src1, dst); |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame] | 439 | case ComparisonOperation::Greater: |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 440 | return configure_comp_func<ComparisonOperation::Greater>(src0, src1, dst); |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame] | 441 | case ComparisonOperation::GreaterEqual: |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 442 | return configure_comp_func<ComparisonOperation::GreaterEqual>(src0, src1, dst); |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame] | 443 | case ComparisonOperation::Less: |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 444 | return configure_comp_func<ComparisonOperation::Less>(src0, src1, dst); |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame] | 445 | case ComparisonOperation::LessEqual: |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 446 | return configure_comp_func<ComparisonOperation::LessEqual>(src0, src1, dst); |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame] | 447 | default: |
| 448 | ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); |
| 449 | } |
Georgios Pinitas | 5fdde99 | 2021-06-25 05:42:57 +0100 | [diff] [blame] | 450 | return { "", nullptr }; |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame] | 451 | } |
| 452 | } // namespace kernels |
| 453 | } // namespace cpu |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 454 | } // namespace arm_compute |