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 | { |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 35 | void NEElementwiseMax::configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info) |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 36 | { |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 37 | ARM_COMPUTE_UNUSED(act_info); |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 38 | auto k = arm_compute::support::cpp14::make_unique<NEArithmeticOperationKernel>(); |
| 39 | k->configure(ArithmeticOperation::MAX, input1, input2, output); |
| 40 | _kernel = std::move(k); |
| 41 | } |
| 42 | |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 43 | 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] | 44 | { |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 45 | ARM_COMPUTE_RETURN_ERROR_ON(act_info.enabled()); |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 46 | return NEArithmeticOperationKernel::validate(ArithmeticOperation::MAX, input1, input2, output); |
| 47 | } |
| 48 | |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 49 | void NEElementwiseMin::configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info) |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 50 | { |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 51 | ARM_COMPUTE_UNUSED(act_info); |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 52 | auto k = arm_compute::support::cpp14::make_unique<NEArithmeticOperationKernel>(); |
| 53 | k->configure(ArithmeticOperation::MIN, input1, input2, output); |
| 54 | _kernel = std::move(k); |
| 55 | } |
| 56 | |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 57 | 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] | 58 | { |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 59 | ARM_COMPUTE_RETURN_ERROR_ON(act_info.enabled()); |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 60 | return NEArithmeticOperationKernel::validate(ArithmeticOperation::MIN, input1, input2, output); |
| 61 | } |
| 62 | |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 63 | void NEElementwiseSquaredDiff::configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info) |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 64 | { |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 65 | ARM_COMPUTE_UNUSED(act_info); |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 66 | auto k = arm_compute::support::cpp14::make_unique<NEArithmeticOperationKernel>(); |
| 67 | k->configure(ArithmeticOperation::SQUARED_DIFF, input1, input2, output); |
| 68 | _kernel = std::move(k); |
| 69 | } |
| 70 | |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 71 | 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] | 72 | { |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 73 | ARM_COMPUTE_RETURN_ERROR_ON(act_info.enabled()); |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 74 | return NEArithmeticOperationKernel::validate(ArithmeticOperation::SQUARED_DIFF, input1, input2, output); |
| 75 | } |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 76 | |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 77 | void NEElementwiseDivision::configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info) |
George Wort | a1e7e28 | 2019-01-15 11:00:29 +0000 | [diff] [blame] | 78 | { |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 79 | ARM_COMPUTE_UNUSED(act_info); |
George Wort | a1e7e28 | 2019-01-15 11:00:29 +0000 | [diff] [blame] | 80 | auto k = arm_compute::support::cpp14::make_unique<NEDivisionOperationKernel>(); |
| 81 | k->configure(input1, input2, output); |
| 82 | _kernel = std::move(k); |
| 83 | } |
| 84 | |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 85 | 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] | 86 | { |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 87 | ARM_COMPUTE_RETURN_ERROR_ON(act_info.enabled()); |
George Wort | a1e7e28 | 2019-01-15 11:00:29 +0000 | [diff] [blame] | 88 | return NEDivisionOperationKernel::validate(input1, input2, output); |
| 89 | } |
| 90 | |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 91 | void NEElementwisePower::configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info) |
Usama Arif | 81e671e | 2019-05-13 13:33:14 +0100 | [diff] [blame] | 92 | { |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 93 | ARM_COMPUTE_UNUSED(act_info); |
Usama Arif | 81e671e | 2019-05-13 13:33:14 +0100 | [diff] [blame] | 94 | auto k = arm_compute::support::cpp14::make_unique<NEPowerOperationKernel>(); |
| 95 | k->configure(input1, input2, output); |
| 96 | _kernel = std::move(k); |
| 97 | } |
| 98 | |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 99 | 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] | 100 | { |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 101 | ARM_COMPUTE_RETURN_ERROR_ON(act_info.enabled()); |
Usama Arif | 81e671e | 2019-05-13 13:33:14 +0100 | [diff] [blame] | 102 | return NEPowerOperationKernel::validate(input1, input2, output); |
| 103 | } |
| 104 | |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 105 | template <ComparisonOperation COP> |
| 106 | void NEElementwiseComparisonStatic<COP>::configure(ITensor *input1, ITensor *input2, ITensor *output) |
| 107 | { |
| 108 | auto k = arm_compute::support::cpp14::make_unique<NEComparisonOperationKernel>(); |
| 109 | k->configure(COP, input1, input2, output); |
| 110 | _kernel = std::move(k); |
| 111 | } |
| 112 | |
| 113 | template <ComparisonOperation COP> |
| 114 | Status NEElementwiseComparisonStatic<COP>::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output) |
| 115 | { |
| 116 | return NEComparisonOperationKernel::validate(COP, input1, input2, output); |
| 117 | } |
| 118 | |
| 119 | void NEElementwiseComparison::configure(ITensor *input1, ITensor *input2, ITensor *output, ComparisonOperation op) |
| 120 | { |
| 121 | auto k = arm_compute::support::cpp14::make_unique<NEComparisonOperationKernel>(); |
| 122 | k->configure(op, input1, input2, output); |
| 123 | _kernel = std::move(k); |
| 124 | } |
| 125 | |
| 126 | Status NEElementwiseComparison::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ComparisonOperation op) |
| 127 | { |
| 128 | return NEComparisonOperationKernel::validate(op, input1, input2, output); |
| 129 | } |
Georgios Pinitas | 83bbf77 | 2019-01-25 16:44:07 +0000 | [diff] [blame] | 130 | |
| 131 | // Supported Specializations |
| 132 | template class NEElementwiseComparisonStatic<ComparisonOperation::Equal>; |
| 133 | template class NEElementwiseComparisonStatic<ComparisonOperation::NotEqual>; |
| 134 | template class NEElementwiseComparisonStatic<ComparisonOperation::Greater>; |
| 135 | template class NEElementwiseComparisonStatic<ComparisonOperation::GreaterEqual>; |
| 136 | template class NEElementwiseComparisonStatic<ComparisonOperation::Less>; |
| 137 | template class NEElementwiseComparisonStatic<ComparisonOperation::LessEqual>; |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 138 | } // namespace arm_compute |