giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 1 | /* |
Michele Di Giorgio | d9eaf61 | 2020-07-08 11:12:57 +0100 | [diff] [blame] | 2 | * Copyright (c) 2018-2020 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 |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 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 | */ |
morgolock | 781d727 | 2020-01-10 10:11:14 +0000 | [diff] [blame] | 24 | #include "arm_compute/core/Validate.h" |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 25 | #include "arm_compute/runtime/NEON/functions/NEElementwiseOperations.h" |
| 26 | #include <arm_compute/core/NEON/kernels/NEElementwiseOperationKernel.h> |
| 27 | |
| 28 | #include "arm_compute/core/ITensor.h" |
Matthew Bentham | 758b5ba | 2020-03-05 23:37:48 +0000 | [diff] [blame] | 29 | #include "support/MemorySupport.h" |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 30 | |
| 31 | #include <utility> |
| 32 | |
| 33 | namespace arm_compute |
| 34 | { |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 35 | namespace experimental |
| 36 | { |
Georgios Pinitas | 09cad72 | 2020-07-22 12:11:20 +0100 | [diff] [blame] | 37 | void NEElementwiseMax::configure(const ITensorInfo *input1, const ITensorInfo *input2, ITensorInfo *output) |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 38 | { |
| 39 | auto k = arm_compute::support::cpp14::make_unique<NEArithmeticOperationKernel>(); |
| 40 | k->configure(ArithmeticOperation::MAX, input1, input2, output); |
| 41 | _kernel = std::move(k); |
| 42 | } |
| 43 | |
Georgios Pinitas | 09cad72 | 2020-07-22 12:11:20 +0100 | [diff] [blame] | 44 | Status NEElementwiseMax::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output) |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 45 | { |
| 46 | return NEArithmeticOperationKernel::validate(ArithmeticOperation::MAX, input1, input2, output); |
| 47 | } |
| 48 | |
Georgios Pinitas | 09cad72 | 2020-07-22 12:11:20 +0100 | [diff] [blame] | 49 | void NEElementwiseMin::configure(const ITensorInfo *input1, const ITensorInfo *input2, ITensorInfo *output) |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 50 | { |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 51 | auto k = arm_compute::support::cpp14::make_unique<NEArithmeticOperationKernel>(); |
| 52 | k->configure(ArithmeticOperation::MIN, input1, input2, output); |
| 53 | _kernel = std::move(k); |
| 54 | } |
| 55 | |
Georgios Pinitas | 09cad72 | 2020-07-22 12:11:20 +0100 | [diff] [blame] | 56 | Status NEElementwiseMin::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output) |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 57 | { |
| 58 | return NEArithmeticOperationKernel::validate(ArithmeticOperation::MIN, input1, input2, output); |
| 59 | } |
| 60 | |
Georgios Pinitas | 09cad72 | 2020-07-22 12:11:20 +0100 | [diff] [blame] | 61 | void NEElementwiseSquaredDiff::configure(const ITensorInfo *input1, const ITensorInfo *input2, ITensorInfo *output) |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 62 | { |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 63 | auto k = arm_compute::support::cpp14::make_unique<NEArithmeticOperationKernel>(); |
| 64 | k->configure(ArithmeticOperation::SQUARED_DIFF, input1, input2, output); |
| 65 | _kernel = std::move(k); |
| 66 | } |
| 67 | |
Georgios Pinitas | 09cad72 | 2020-07-22 12:11:20 +0100 | [diff] [blame] | 68 | Status NEElementwiseSquaredDiff::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output) |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 69 | { |
| 70 | return NEArithmeticOperationKernel::validate(ArithmeticOperation::SQUARED_DIFF, input1, input2, output); |
| 71 | } |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 72 | |
Georgios Pinitas | 09cad72 | 2020-07-22 12:11:20 +0100 | [diff] [blame] | 73 | void NEElementwiseDivision::configure(const ITensorInfo *input1, const ITensorInfo *input2, ITensorInfo *output) |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 74 | { |
George Wort | a1e7e28 | 2019-01-15 11:00:29 +0000 | [diff] [blame] | 75 | auto k = arm_compute::support::cpp14::make_unique<NEDivisionOperationKernel>(); |
| 76 | k->configure(input1, input2, output); |
| 77 | _kernel = std::move(k); |
| 78 | } |
| 79 | |
Georgios Pinitas | 09cad72 | 2020-07-22 12:11:20 +0100 | [diff] [blame] | 80 | Status NEElementwiseDivision::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output) |
George Wort | a1e7e28 | 2019-01-15 11:00:29 +0000 | [diff] [blame] | 81 | { |
| 82 | return NEDivisionOperationKernel::validate(input1, input2, output); |
| 83 | } |
| 84 | |
Georgios Pinitas | 09cad72 | 2020-07-22 12:11:20 +0100 | [diff] [blame] | 85 | void NEElementwisePower::configure(const ITensorInfo *input1, const ITensorInfo *input2, ITensorInfo *output) |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 86 | { |
Usama Arif | 81e671e | 2019-05-13 13:33:14 +0100 | [diff] [blame] | 87 | auto k = arm_compute::support::cpp14::make_unique<NEPowerOperationKernel>(); |
| 88 | k->configure(input1, input2, output); |
| 89 | _kernel = std::move(k); |
| 90 | } |
| 91 | |
Georgios Pinitas | 09cad72 | 2020-07-22 12:11:20 +0100 | [diff] [blame] | 92 | Status NEElementwisePower::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output) |
Usama Arif | 81e671e | 2019-05-13 13:33:14 +0100 | [diff] [blame] | 93 | { |
| 94 | return NEPowerOperationKernel::validate(input1, input2, output); |
| 95 | } |
| 96 | |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 97 | template <ComparisonOperation COP> |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 98 | void NEElementwiseComparisonStatic<COP>::configure(const ITensorInfo *input1, const ITensorInfo *input2, ITensorInfo *output) |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 99 | { |
| 100 | auto k = arm_compute::support::cpp14::make_unique<NEComparisonOperationKernel>(); |
| 101 | k->configure(COP, input1, input2, output); |
| 102 | _kernel = std::move(k); |
| 103 | } |
| 104 | |
| 105 | template <ComparisonOperation COP> |
| 106 | Status NEElementwiseComparisonStatic<COP>::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output) |
| 107 | { |
| 108 | return NEComparisonOperationKernel::validate(COP, input1, input2, output); |
| 109 | } |
| 110 | |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 111 | void NEElementwiseComparison::configure(const ITensorInfo *input1, const ITensorInfo *input2, ITensorInfo *output, ComparisonOperation op) |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 112 | { |
| 113 | auto k = arm_compute::support::cpp14::make_unique<NEComparisonOperationKernel>(); |
| 114 | k->configure(op, input1, input2, output); |
| 115 | _kernel = std::move(k); |
| 116 | } |
| 117 | |
| 118 | Status NEElementwiseComparison::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ComparisonOperation op) |
| 119 | { |
| 120 | return NEComparisonOperationKernel::validate(op, input1, input2, output); |
| 121 | } |
Georgios Pinitas | 83bbf77 | 2019-01-25 16:44:07 +0000 | [diff] [blame] | 122 | |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 123 | // Supported Specializations |
| 124 | template class NEElementwiseComparisonStatic<ComparisonOperation::Equal>; |
| 125 | template class NEElementwiseComparisonStatic<ComparisonOperation::NotEqual>; |
| 126 | template class NEElementwiseComparisonStatic<ComparisonOperation::Greater>; |
| 127 | template class NEElementwiseComparisonStatic<ComparisonOperation::GreaterEqual>; |
| 128 | template class NEElementwiseComparisonStatic<ComparisonOperation::Less>; |
| 129 | template class NEElementwiseComparisonStatic<ComparisonOperation::LessEqual>; |
| 130 | } // namespace experimental |
| 131 | |
| 132 | struct NEElementwiseMax::Impl |
| 133 | { |
| 134 | const ITensor *src_0{ nullptr }; |
| 135 | const ITensor *src_1{ nullptr }; |
| 136 | ITensor *dst{ nullptr }; |
| 137 | std::unique_ptr<experimental::NEElementwiseMax> op{ nullptr }; |
| 138 | }; |
| 139 | |
| 140 | NEElementwiseMax::NEElementwiseMax() |
| 141 | : _impl(support::cpp14::make_unique<Impl>()) |
| 142 | { |
| 143 | } |
| 144 | NEElementwiseMax::NEElementwiseMax(NEElementwiseMax &&) = default; |
| 145 | NEElementwiseMax &NEElementwiseMax::operator=(NEElementwiseMax &&) = default; |
| 146 | NEElementwiseMax::~NEElementwiseMax() = default; |
| 147 | |
| 148 | void NEElementwiseMax::configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info) |
| 149 | { |
Georgios Pinitas | 09cad72 | 2020-07-22 12:11:20 +0100 | [diff] [blame] | 150 | ARM_COMPUTE_UNUSED(act_info); |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 151 | _impl->src_0 = input1; |
| 152 | _impl->src_1 = input2; |
| 153 | _impl->dst = output; |
| 154 | _impl->op = arm_compute::support::cpp14::make_unique<experimental::NEElementwiseMax>(); |
Georgios Pinitas | 09cad72 | 2020-07-22 12:11:20 +0100 | [diff] [blame] | 155 | _impl->op->configure(input1->info(), input2->info(), output->info()); |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | Status NEElementwiseMax::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info) |
| 159 | { |
| 160 | ARM_COMPUTE_RETURN_ERROR_ON(act_info.enabled()); |
Georgios Pinitas | 09cad72 | 2020-07-22 12:11:20 +0100 | [diff] [blame] | 161 | return experimental::NEElementwiseMax::validate(input1, input2, output); |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | void NEElementwiseMax::run() |
| 165 | { |
| 166 | const InputTensorMap src{ { TensorType::ACL_SRC_0, _impl->src_0 }, { TensorType::ACL_SRC_1, _impl->src_1 } }; |
| 167 | const OutputTensorMap dst{ { TensorType::ACL_DST, _impl->dst } }; |
| 168 | _impl->op->run(src, dst, {}); |
| 169 | } |
| 170 | |
| 171 | struct NEElementwiseMin::Impl |
| 172 | { |
| 173 | const ITensor *src_0{ nullptr }; |
| 174 | const ITensor *src_1{ nullptr }; |
| 175 | ITensor *dst{ nullptr }; |
| 176 | std::unique_ptr<experimental::NEElementwiseMin> op{ nullptr }; |
| 177 | }; |
| 178 | |
| 179 | NEElementwiseMin::NEElementwiseMin() |
| 180 | : _impl(support::cpp14::make_unique<Impl>()) |
| 181 | { |
| 182 | } |
| 183 | NEElementwiseMin::NEElementwiseMin(NEElementwiseMin &&) = default; |
| 184 | NEElementwiseMin &NEElementwiseMin::operator=(NEElementwiseMin &&) = default; |
| 185 | NEElementwiseMin::~NEElementwiseMin() = default; |
| 186 | |
| 187 | void NEElementwiseMin::configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info) |
| 188 | { |
Georgios Pinitas | 09cad72 | 2020-07-22 12:11:20 +0100 | [diff] [blame] | 189 | ARM_COMPUTE_UNUSED(act_info); |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 190 | _impl->src_0 = input1; |
| 191 | _impl->src_1 = input2; |
| 192 | _impl->dst = output; |
| 193 | _impl->op = arm_compute::support::cpp14::make_unique<experimental::NEElementwiseMin>(); |
Georgios Pinitas | 09cad72 | 2020-07-22 12:11:20 +0100 | [diff] [blame] | 194 | _impl->op->configure(input1->info(), input2->info(), output->info()); |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | Status NEElementwiseMin::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info) |
| 198 | { |
| 199 | ARM_COMPUTE_RETURN_ERROR_ON(act_info.enabled()); |
Georgios Pinitas | 09cad72 | 2020-07-22 12:11:20 +0100 | [diff] [blame] | 200 | return experimental::NEElementwiseMin::validate(input1, input2, output); |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 201 | } |
| 202 | |
| 203 | void NEElementwiseMin::run() |
| 204 | { |
| 205 | const InputTensorMap src{ { TensorType::ACL_SRC_0, _impl->src_0 }, { TensorType::ACL_SRC_1, _impl->src_1 } }; |
| 206 | const OutputTensorMap dst{ { TensorType::ACL_DST, _impl->dst } }; |
| 207 | _impl->op->run(src, dst, {}); |
| 208 | } |
| 209 | |
| 210 | struct NEElementwiseSquaredDiff::Impl |
| 211 | { |
| 212 | const ITensor *src_0{ nullptr }; |
| 213 | const ITensor *src_1{ nullptr }; |
| 214 | ITensor *dst{ nullptr }; |
| 215 | std::unique_ptr<experimental::NEElementwiseSquaredDiff> op{ nullptr }; |
| 216 | }; |
| 217 | |
| 218 | NEElementwiseSquaredDiff::NEElementwiseSquaredDiff() |
| 219 | : _impl(support::cpp14::make_unique<Impl>()) |
| 220 | { |
| 221 | } |
| 222 | NEElementwiseSquaredDiff::NEElementwiseSquaredDiff(NEElementwiseSquaredDiff &&) = default; |
| 223 | NEElementwiseSquaredDiff &NEElementwiseSquaredDiff::operator=(NEElementwiseSquaredDiff &&) = default; |
| 224 | NEElementwiseSquaredDiff::~NEElementwiseSquaredDiff() = default; |
| 225 | |
| 226 | void NEElementwiseSquaredDiff::configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info) |
| 227 | { |
Georgios Pinitas | 09cad72 | 2020-07-22 12:11:20 +0100 | [diff] [blame] | 228 | ARM_COMPUTE_UNUSED(act_info); |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 229 | _impl->src_0 = input1; |
| 230 | _impl->src_1 = input2; |
| 231 | _impl->dst = output; |
| 232 | _impl->op = arm_compute::support::cpp14::make_unique<experimental::NEElementwiseSquaredDiff>(); |
Georgios Pinitas | 09cad72 | 2020-07-22 12:11:20 +0100 | [diff] [blame] | 233 | _impl->op->configure(input1->info(), input2->info(), output->info()); |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 234 | } |
| 235 | |
| 236 | Status NEElementwiseSquaredDiff::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info) |
| 237 | { |
| 238 | ARM_COMPUTE_RETURN_ERROR_ON(act_info.enabled()); |
Georgios Pinitas | 09cad72 | 2020-07-22 12:11:20 +0100 | [diff] [blame] | 239 | return experimental::NEElementwiseSquaredDiff::validate(input1, input2, output); |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 240 | } |
| 241 | |
| 242 | void NEElementwiseSquaredDiff::run() |
| 243 | { |
| 244 | const InputTensorMap src{ { TensorType::ACL_SRC_0, _impl->src_0 }, { TensorType::ACL_SRC_1, _impl->src_1 } }; |
| 245 | const OutputTensorMap dst{ { TensorType::ACL_DST, _impl->dst } }; |
| 246 | _impl->op->run(src, dst, {}); |
| 247 | } |
| 248 | |
| 249 | struct NEElementwiseDivision::Impl |
| 250 | { |
| 251 | const ITensor *src_0{ nullptr }; |
| 252 | const ITensor *src_1{ nullptr }; |
| 253 | ITensor *dst{ nullptr }; |
| 254 | std::unique_ptr<experimental::NEElementwiseDivision> op{ nullptr }; |
| 255 | }; |
| 256 | |
| 257 | NEElementwiseDivision::NEElementwiseDivision() |
| 258 | : _impl(support::cpp14::make_unique<Impl>()) |
| 259 | { |
| 260 | } |
| 261 | NEElementwiseDivision::NEElementwiseDivision(NEElementwiseDivision &&) = default; |
| 262 | NEElementwiseDivision &NEElementwiseDivision::operator=(NEElementwiseDivision &&) = default; |
| 263 | NEElementwiseDivision::~NEElementwiseDivision() = default; |
| 264 | |
| 265 | void NEElementwiseDivision::configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info) |
| 266 | { |
| 267 | ARM_COMPUTE_UNUSED(act_info); |
| 268 | _impl->src_0 = input1; |
| 269 | _impl->src_1 = input2; |
| 270 | _impl->dst = output; |
| 271 | _impl->op = arm_compute::support::cpp14::make_unique<experimental::NEElementwiseDivision>(); |
Georgios Pinitas | 09cad72 | 2020-07-22 12:11:20 +0100 | [diff] [blame] | 272 | _impl->op->configure(input1->info(), input2->info(), output->info()); |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | Status NEElementwiseDivision::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info) |
| 276 | { |
| 277 | ARM_COMPUTE_RETURN_ERROR_ON(act_info.enabled()); |
Georgios Pinitas | 09cad72 | 2020-07-22 12:11:20 +0100 | [diff] [blame] | 278 | return experimental::NEElementwiseDivision::validate(input1, input2, output); |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | void NEElementwiseDivision::run() |
| 282 | { |
| 283 | const InputTensorMap src{ { TensorType::ACL_SRC_0, _impl->src_0 }, { TensorType::ACL_SRC_1, _impl->src_1 } }; |
| 284 | const OutputTensorMap dst{ { TensorType::ACL_DST, _impl->dst } }; |
| 285 | _impl->op->run(src, dst, {}); |
| 286 | } |
| 287 | |
| 288 | struct NEElementwisePower::Impl |
| 289 | { |
| 290 | const ITensor *src_0{ nullptr }; |
| 291 | const ITensor *src_1{ nullptr }; |
| 292 | ITensor *dst{ nullptr }; |
| 293 | std::unique_ptr<experimental::NEElementwisePower> op{ nullptr }; |
| 294 | }; |
| 295 | |
| 296 | NEElementwisePower::NEElementwisePower() |
| 297 | : _impl(support::cpp14::make_unique<Impl>()) |
| 298 | { |
| 299 | } |
| 300 | NEElementwisePower::NEElementwisePower(NEElementwisePower &&) = default; |
| 301 | NEElementwisePower &NEElementwisePower::operator=(NEElementwisePower &&) = default; |
| 302 | NEElementwisePower::~NEElementwisePower() = default; |
| 303 | |
| 304 | void NEElementwisePower::configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info) |
| 305 | { |
| 306 | ARM_COMPUTE_UNUSED(act_info); |
| 307 | _impl->src_0 = input1; |
| 308 | _impl->src_1 = input2; |
| 309 | _impl->dst = output; |
| 310 | _impl->op = arm_compute::support::cpp14::make_unique<experimental::NEElementwisePower>(); |
Georgios Pinitas | 09cad72 | 2020-07-22 12:11:20 +0100 | [diff] [blame] | 311 | _impl->op->configure(input1->info(), input2->info(), output->info()); |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | Status NEElementwisePower::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info) |
| 315 | { |
| 316 | ARM_COMPUTE_RETURN_ERROR_ON(act_info.enabled()); |
Georgios Pinitas | 09cad72 | 2020-07-22 12:11:20 +0100 | [diff] [blame] | 317 | return experimental::NEElementwisePower::validate(input1, input2, output); |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | void NEElementwisePower::run() |
| 321 | { |
| 322 | const InputTensorMap src{ { TensorType::ACL_SRC_0, _impl->src_0 }, { TensorType::ACL_SRC_1, _impl->src_1 } }; |
| 323 | const OutputTensorMap dst{ { TensorType::ACL_DST, _impl->dst } }; |
| 324 | _impl->op->run(src, dst, {}); |
| 325 | } |
| 326 | |
| 327 | template <ComparisonOperation COP> |
| 328 | struct NEElementwiseComparisonStatic<COP>::Impl |
| 329 | { |
| 330 | const ITensor *src_0{ nullptr }; |
| 331 | const ITensor *src_1{ nullptr }; |
| 332 | ITensor *dst{ nullptr }; |
| 333 | std::unique_ptr<experimental::NEElementwiseComparisonStatic<COP>> op{ nullptr }; |
| 334 | }; |
| 335 | |
| 336 | template <ComparisonOperation COP> |
| 337 | NEElementwiseComparisonStatic<COP>::NEElementwiseComparisonStatic() |
| 338 | : _impl(support::cpp14::make_unique<Impl>()) |
| 339 | { |
| 340 | } |
| 341 | template <ComparisonOperation COP> |
| 342 | NEElementwiseComparisonStatic<COP>::NEElementwiseComparisonStatic(NEElementwiseComparisonStatic &&) = default; |
| 343 | template <ComparisonOperation COP> |
| 344 | NEElementwiseComparisonStatic<COP> &NEElementwiseComparisonStatic<COP>::operator=(NEElementwiseComparisonStatic &&) = default; |
| 345 | template <ComparisonOperation COP> |
| 346 | NEElementwiseComparisonStatic<COP>::~NEElementwiseComparisonStatic() = default; |
| 347 | |
| 348 | template <ComparisonOperation COP> |
| 349 | void NEElementwiseComparisonStatic<COP>::configure(ITensor *input1, ITensor *input2, ITensor *output) |
| 350 | { |
| 351 | _impl->src_0 = input1; |
| 352 | _impl->src_1 = input2; |
| 353 | _impl->dst = output; |
| 354 | _impl->op = arm_compute::support::cpp14::make_unique<experimental::NEElementwiseComparisonStatic<COP>>(); |
| 355 | _impl->op->configure(input1->info(), input2->info(), output->info()); |
| 356 | } |
| 357 | |
| 358 | template <ComparisonOperation COP> |
| 359 | Status NEElementwiseComparisonStatic<COP>::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output) |
| 360 | { |
| 361 | return experimental::NEElementwiseComparisonStatic<COP>::validate(input1, input2, output); |
| 362 | } |
| 363 | |
| 364 | template <ComparisonOperation COP> |
| 365 | void NEElementwiseComparisonStatic<COP>::run() |
| 366 | { |
| 367 | const InputTensorMap src{ { TensorType::ACL_SRC_0, _impl->src_0 }, { TensorType::ACL_SRC_1, _impl->src_1 } }; |
| 368 | const OutputTensorMap dst{ { TensorType::ACL_DST, _impl->dst } }; |
| 369 | _impl->op->run(src, dst, {}); |
| 370 | } |
| 371 | |
| 372 | struct NEElementwiseComparison::Impl |
| 373 | { |
| 374 | const ITensor *src_0{ nullptr }; |
| 375 | const ITensor *src_1{ nullptr }; |
| 376 | ITensor *dst{ nullptr }; |
| 377 | std::unique_ptr<experimental::NEElementwiseComparison> op{ nullptr }; |
| 378 | }; |
| 379 | |
| 380 | NEElementwiseComparison::NEElementwiseComparison() |
| 381 | : _impl(support::cpp14::make_unique<Impl>()) |
| 382 | { |
| 383 | } |
| 384 | NEElementwiseComparison::NEElementwiseComparison(NEElementwiseComparison &&) = default; |
| 385 | NEElementwiseComparison &NEElementwiseComparison::operator=(NEElementwiseComparison &&) = default; |
| 386 | NEElementwiseComparison::~NEElementwiseComparison() = default; |
| 387 | |
| 388 | void NEElementwiseComparison::configure(ITensor *input1, ITensor *input2, ITensor *output, ComparisonOperation op) |
| 389 | { |
| 390 | _impl->src_0 = input1; |
| 391 | _impl->src_1 = input2; |
| 392 | _impl->dst = output; |
| 393 | _impl->op = arm_compute::support::cpp14::make_unique<experimental::NEElementwiseComparison>(); |
| 394 | _impl->op->configure(input1->info(), input2->info(), output->info(), op); |
| 395 | } |
| 396 | |
| 397 | Status NEElementwiseComparison::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ComparisonOperation op) |
| 398 | { |
| 399 | return experimental::NEElementwiseComparison::validate(input1, input2, output, op); |
| 400 | } |
| 401 | |
| 402 | void NEElementwiseComparison::run() |
| 403 | { |
| 404 | const InputTensorMap src{ { TensorType::ACL_SRC_0, _impl->src_0 }, { TensorType::ACL_SRC_1, _impl->src_1 } }; |
| 405 | const OutputTensorMap dst{ { TensorType::ACL_DST, _impl->dst } }; |
| 406 | _impl->op->run(src, dst, {}); |
| 407 | } |
| 408 | |
Georgios Pinitas | 83bbf77 | 2019-01-25 16:44:07 +0000 | [diff] [blame] | 409 | // Supported Specializations |
| 410 | template class NEElementwiseComparisonStatic<ComparisonOperation::Equal>; |
| 411 | template class NEElementwiseComparisonStatic<ComparisonOperation::NotEqual>; |
| 412 | template class NEElementwiseComparisonStatic<ComparisonOperation::Greater>; |
| 413 | template class NEElementwiseComparisonStatic<ComparisonOperation::GreaterEqual>; |
| 414 | template class NEElementwiseComparisonStatic<ComparisonOperation::Less>; |
| 415 | template class NEElementwiseComparisonStatic<ComparisonOperation::LessEqual>; |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 416 | } // namespace arm_compute |