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