giuros01 | 164a272 | 2018-11-20 18:34:46 +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 | 164a272 | 2018-11-20 18:34:46 +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 | */ |
giuros01 | 1e6e1b8 | 2019-05-14 16:12:53 +0100 | [diff] [blame] | 24 | #include "arm_compute/runtime/CL/functions/CLElementwiseOperations.h" |
| 25 | |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 26 | #include "arm_compute/core/CL/ICLTensor.h" |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 27 | #include "arm_compute/runtime/CL/CLScheduler.h" |
Sang-Hoon Park | bef7fa2 | 2020-10-21 15:58:54 +0100 | [diff] [blame] | 28 | #include "src/core/CL/kernels/CLElementwiseOperationKernel.h" |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 29 | |
| 30 | #include <utility> |
| 31 | |
| 32 | namespace arm_compute |
| 33 | { |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 34 | namespace experimental |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 35 | { |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 36 | CLArithmeticAddition::CLArithmeticAddition() |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 37 | { |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 38 | } |
| 39 | |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 40 | void CLArithmeticAddition::configure(const CLCompileContext &compile_context, ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, ConvertPolicy policy, const ActivationLayerInfo &act_info) |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 41 | { |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 42 | auto k = std::make_unique<CLSaturatedArithmeticOperationKernel>(); |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 43 | k->configure(compile_context, ArithmeticOperation::ADD, input1, input2, output, policy, act_info); |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 44 | _kernel = std::move(k); |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 45 | } |
| 46 | |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 47 | Status CLArithmeticAddition::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ConvertPolicy policy, const ActivationLayerInfo &act_info) |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 48 | { |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 49 | return CLSaturatedArithmeticOperationKernel::validate(ArithmeticOperation::ADD, input1, input2, output, policy, act_info); |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 50 | } |
| 51 | |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 52 | void CLArithmeticAddition::run(ITensorPack &tensors) |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 53 | { |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 54 | ICLOperator::run(tensors); |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 55 | } |
| 56 | |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 57 | CLArithmeticSubtraction::CLArithmeticSubtraction() |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 58 | { |
| 59 | } |
| 60 | void CLArithmeticSubtraction::configure(const CLCompileContext &compile_context, ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, ConvertPolicy policy, |
| 61 | const ActivationLayerInfo &act_info) |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 62 | { |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 63 | auto k = std::make_unique<CLSaturatedArithmeticOperationKernel>(); |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 64 | k->configure(compile_context, ArithmeticOperation::SUB, input1, input2, output, policy, act_info); |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 65 | _kernel = std::move(k); |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 66 | } |
| 67 | |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 68 | Status CLArithmeticSubtraction::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ConvertPolicy policy, const ActivationLayerInfo &act_info) |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 69 | { |
| 70 | ARM_COMPUTE_UNUSED(policy); |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 71 | return CLSaturatedArithmeticOperationKernel::validate(ArithmeticOperation::SUB, input1, input2, output, policy, act_info); |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 72 | } |
| 73 | |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 74 | void CLArithmeticSubtraction::run(ITensorPack &tensors) |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 75 | { |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 76 | ICLOperator::run(tensors); |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 77 | } |
| 78 | |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 79 | CLArithmeticDivision::CLArithmeticDivision() |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 80 | { |
| 81 | } |
| 82 | |
| 83 | void CLArithmeticDivision::configure(const CLCompileContext &compile_context, ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, const ActivationLayerInfo &act_info) |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 84 | { |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 85 | auto k = std::make_unique<CLArithmeticOperationKernel>(); |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 86 | k->configure(compile_context, ArithmeticOperation::DIV, input1, input2, output, act_info); |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 87 | _kernel = std::move(k); |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 88 | } |
| 89 | |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 90 | Status CLArithmeticDivision::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info) |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 91 | { |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 92 | return CLArithmeticOperationKernel::validate(ArithmeticOperation::DIV, input1, input2, output, act_info); |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 93 | } |
| 94 | |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 95 | void CLArithmeticDivision::run(ITensorPack &tensors) |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 96 | { |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 97 | ICLOperator::run(tensors); |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 98 | } |
| 99 | |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 100 | CLElementwiseMax::CLElementwiseMax() |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 101 | { |
| 102 | } |
| 103 | |
| 104 | void CLElementwiseMax::configure(const CLCompileContext &compile_context, ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, const ActivationLayerInfo &act_info) |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 105 | { |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 106 | auto k = std::make_unique<CLArithmeticOperationKernel>(); |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 107 | k->configure(compile_context, ArithmeticOperation::MAX, input1, input2, output, act_info); |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 108 | _kernel = std::move(k); |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 109 | } |
| 110 | |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 111 | Status CLElementwiseMax::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info) |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 112 | { |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 113 | return CLArithmeticOperationKernel::validate(ArithmeticOperation::MAX, input1, input2, output, act_info); |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 114 | } |
| 115 | |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 116 | void CLElementwiseMax::run(ITensorPack &tensors) |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 117 | { |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 118 | ICLOperator::run(tensors); |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 119 | } |
| 120 | |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 121 | CLElementwiseMin::CLElementwiseMin() |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 122 | { |
| 123 | } |
| 124 | |
| 125 | void CLElementwiseMin::configure(const CLCompileContext &compile_context, ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, const ActivationLayerInfo &act_info) |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 126 | { |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 127 | auto k = std::make_unique<CLArithmeticOperationKernel>(); |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 128 | k->configure(compile_context, ArithmeticOperation::MIN, input1, input2, output, act_info); |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 129 | _kernel = std::move(k); |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 130 | } |
| 131 | |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 132 | Status CLElementwiseMin::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info) |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 133 | { |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 134 | return CLArithmeticOperationKernel::validate(ArithmeticOperation::MIN, input1, input2, output, act_info); |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 135 | } |
| 136 | |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 137 | void CLElementwiseMin::run(ITensorPack &tensors) |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 138 | { |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 139 | ICLOperator::run(tensors); |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 140 | } |
| 141 | |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 142 | CLElementwiseSquaredDiff::CLElementwiseSquaredDiff() |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 143 | { |
| 144 | } |
| 145 | |
| 146 | void CLElementwiseSquaredDiff::configure(const CLCompileContext &compile_context, ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, const ActivationLayerInfo &act_info) |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 147 | { |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 148 | auto k = std::make_unique<CLArithmeticOperationKernel>(); |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 149 | k->configure(compile_context, ArithmeticOperation::SQUARED_DIFF, input1, input2, output, act_info); |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 150 | _kernel = std::move(k); |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 151 | } |
| 152 | |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 153 | Status CLElementwiseSquaredDiff::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info) |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 154 | { |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 155 | return CLArithmeticOperationKernel::validate(ArithmeticOperation::SQUARED_DIFF, input1, input2, output, act_info); |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 156 | } |
Usama Arif | 52c54f6 | 2019-05-14 10:22:36 +0100 | [diff] [blame] | 157 | |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 158 | void CLElementwiseSquaredDiff::run(ITensorPack &tensors) |
Usama Arif | 52c54f6 | 2019-05-14 10:22:36 +0100 | [diff] [blame] | 159 | { |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 160 | ICLOperator::run(tensors); |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 161 | } |
| 162 | |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 163 | CLElementwisePower::CLElementwisePower() |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 164 | { |
| 165 | } |
| 166 | |
| 167 | void CLElementwisePower::configure(const CLCompileContext &compile_context, ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, const ActivationLayerInfo &act_info) |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 168 | { |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 169 | auto k = std::make_unique<CLArithmeticOperationKernel>(); |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 170 | k->configure(compile_context, ArithmeticOperation::POWER, input1, input2, output, act_info); |
Usama Arif | 52c54f6 | 2019-05-14 10:22:36 +0100 | [diff] [blame] | 171 | _kernel = std::move(k); |
Usama Arif | 52c54f6 | 2019-05-14 10:22:36 +0100 | [diff] [blame] | 172 | } |
| 173 | |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 174 | Status CLElementwisePower::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info) |
Usama Arif | 52c54f6 | 2019-05-14 10:22:36 +0100 | [diff] [blame] | 175 | { |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 176 | return CLArithmeticOperationKernel::validate(ArithmeticOperation::POWER, input1, input2, output, act_info); |
Usama Arif | 52c54f6 | 2019-05-14 10:22:36 +0100 | [diff] [blame] | 177 | } |
| 178 | |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 179 | void CLElementwisePower::run(ITensorPack &tensors) |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 180 | { |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 181 | ICLOperator::run(tensors); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 182 | } |
| 183 | } // namespace experimental |
| 184 | |
| 185 | struct CLArithmeticAddition::Impl |
| 186 | { |
| 187 | const ICLTensor *src_0{ nullptr }; |
| 188 | const ICLTensor *src_1{ nullptr }; |
| 189 | ICLTensor *dst{ nullptr }; |
| 190 | std::unique_ptr<experimental::CLArithmeticAddition> op{ nullptr }; |
| 191 | }; |
| 192 | |
| 193 | CLArithmeticAddition::CLArithmeticAddition() |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 194 | : _impl(std::make_unique<Impl>()) |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 195 | { |
| 196 | } |
| 197 | CLArithmeticAddition::CLArithmeticAddition(CLArithmeticAddition &&) = default; |
| 198 | CLArithmeticAddition &CLArithmeticAddition::operator=(CLArithmeticAddition &&) = default; |
| 199 | CLArithmeticAddition::~CLArithmeticAddition() = default; |
| 200 | |
| 201 | void CLArithmeticAddition::configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, ConvertPolicy policy, const ActivationLayerInfo &act_info) |
| 202 | { |
| 203 | configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, policy, act_info); |
| 204 | } |
| 205 | |
| 206 | void CLArithmeticAddition::configure(const CLCompileContext &compile_context, const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output, ConvertPolicy policy, |
| 207 | const ActivationLayerInfo &act_info) |
| 208 | { |
| 209 | _impl->src_0 = input1; |
| 210 | _impl->src_1 = input2; |
| 211 | _impl->dst = output; |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 212 | _impl->op = std::make_unique<experimental::CLArithmeticAddition>(); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 213 | _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), policy, act_info); |
| 214 | } |
| 215 | |
| 216 | Status CLArithmeticAddition::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ConvertPolicy policy, const ActivationLayerInfo &act_info) |
| 217 | { |
| 218 | return experimental::CLArithmeticAddition::validate(input1, input2, output, policy, act_info); |
| 219 | } |
| 220 | |
| 221 | void CLArithmeticAddition::run() |
| 222 | { |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 223 | ITensorPack pack; |
| 224 | pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0); |
| 225 | pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1); |
| 226 | pack.add_tensor(TensorType::ACL_DST, _impl->dst); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 227 | |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 228 | _impl->op->run(pack); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 229 | } |
| 230 | |
| 231 | struct CLArithmeticSubtraction::Impl |
| 232 | { |
| 233 | const ICLTensor *src_0{ nullptr }; |
| 234 | const ICLTensor *src_1{ nullptr }; |
| 235 | ICLTensor *dst{ nullptr }; |
| 236 | std::unique_ptr<experimental::CLArithmeticSubtraction> op{ nullptr }; |
| 237 | }; |
| 238 | |
| 239 | CLArithmeticSubtraction::CLArithmeticSubtraction() |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 240 | : _impl(std::make_unique<Impl>()) |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 241 | { |
| 242 | } |
| 243 | CLArithmeticSubtraction::CLArithmeticSubtraction(CLArithmeticSubtraction &&) = default; |
| 244 | CLArithmeticSubtraction &CLArithmeticSubtraction::operator=(CLArithmeticSubtraction &&) = default; |
| 245 | CLArithmeticSubtraction::~CLArithmeticSubtraction() = default; |
| 246 | |
| 247 | void CLArithmeticSubtraction::configure(const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output, ConvertPolicy policy, const ActivationLayerInfo &act_info) |
| 248 | { |
| 249 | configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, policy, act_info); |
| 250 | } |
| 251 | |
| 252 | void CLArithmeticSubtraction::configure(const CLCompileContext &compile_context, const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output, ConvertPolicy policy, |
| 253 | const ActivationLayerInfo &act_info) |
| 254 | { |
| 255 | _impl->src_0 = input1; |
| 256 | _impl->src_1 = input2; |
| 257 | _impl->dst = output; |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 258 | _impl->op = std::make_unique<experimental::CLArithmeticSubtraction>(); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 259 | _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), policy, act_info); |
| 260 | } |
| 261 | |
| 262 | Status CLArithmeticSubtraction::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ConvertPolicy policy, const ActivationLayerInfo &act_info) |
| 263 | { |
| 264 | return experimental::CLArithmeticSubtraction::validate(input1, input2, output, policy, act_info); |
| 265 | } |
| 266 | |
| 267 | void CLArithmeticSubtraction::run() |
| 268 | { |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 269 | ITensorPack pack; |
| 270 | pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0); |
| 271 | pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1); |
| 272 | pack.add_tensor(TensorType::ACL_DST, _impl->dst); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 273 | |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 274 | _impl->op->run(pack); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 275 | } |
| 276 | |
| 277 | struct CLArithmeticDivision::Impl |
| 278 | { |
| 279 | const ICLTensor *src_0{ nullptr }; |
| 280 | const ICLTensor *src_1{ nullptr }; |
| 281 | ICLTensor *dst{ nullptr }; |
| 282 | std::unique_ptr<experimental::CLArithmeticDivision> op{ nullptr }; |
| 283 | }; |
| 284 | |
| 285 | CLArithmeticDivision::CLArithmeticDivision() |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 286 | : _impl(std::make_unique<Impl>()) |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 287 | { |
| 288 | } |
| 289 | CLArithmeticDivision::CLArithmeticDivision(CLArithmeticDivision &&) = default; |
| 290 | CLArithmeticDivision &CLArithmeticDivision::operator=(CLArithmeticDivision &&) = default; |
| 291 | CLArithmeticDivision::~CLArithmeticDivision() = default; |
| 292 | |
| 293 | void CLArithmeticDivision::configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info) |
| 294 | { |
| 295 | configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, act_info); |
| 296 | } |
| 297 | |
| 298 | void CLArithmeticDivision::configure(const CLCompileContext &compile_context, const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info) |
| 299 | { |
| 300 | _impl->src_0 = input1; |
| 301 | _impl->src_1 = input2; |
| 302 | _impl->dst = output; |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 303 | _impl->op = std::make_unique<experimental::CLArithmeticDivision>(); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 304 | _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), act_info); |
| 305 | } |
| 306 | |
| 307 | Status CLArithmeticDivision::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info) |
| 308 | { |
| 309 | return experimental::CLArithmeticDivision::validate(input1, input2, output, act_info); |
| 310 | } |
| 311 | |
| 312 | void CLArithmeticDivision::run() |
| 313 | { |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 314 | ITensorPack pack; |
| 315 | pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0); |
| 316 | pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1); |
| 317 | pack.add_tensor(TensorType::ACL_DST, _impl->dst); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 318 | |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 319 | _impl->op->run(pack); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 320 | } |
| 321 | |
| 322 | struct CLElementwiseMax::Impl |
| 323 | { |
| 324 | const ICLTensor *src_0{ nullptr }; |
| 325 | const ICLTensor *src_1{ nullptr }; |
| 326 | ICLTensor *dst{ nullptr }; |
| 327 | std::unique_ptr<experimental::CLElementwiseMax> op{ nullptr }; |
| 328 | }; |
| 329 | |
| 330 | CLElementwiseMax::CLElementwiseMax() |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 331 | : _impl(std::make_unique<Impl>()) |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 332 | { |
| 333 | } |
| 334 | CLElementwiseMax::CLElementwiseMax(CLElementwiseMax &&) = default; |
| 335 | CLElementwiseMax &CLElementwiseMax::operator=(CLElementwiseMax &&) = default; |
| 336 | CLElementwiseMax::~CLElementwiseMax() = default; |
| 337 | |
| 338 | void CLElementwiseMax::configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info) |
| 339 | { |
| 340 | configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, act_info); |
| 341 | } |
| 342 | |
| 343 | void CLElementwiseMax::configure(const CLCompileContext &compile_context, ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info) |
| 344 | { |
| 345 | _impl->src_0 = input1; |
| 346 | _impl->src_1 = input2; |
| 347 | _impl->dst = output; |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 348 | _impl->op = std::make_unique<experimental::CLElementwiseMax>(); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 349 | _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), act_info); |
| 350 | } |
| 351 | |
| 352 | Status CLElementwiseMax::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info) |
| 353 | { |
| 354 | return experimental::CLElementwiseMax::validate(input1, input2, output, act_info); |
| 355 | } |
| 356 | |
| 357 | void CLElementwiseMax::run() |
| 358 | { |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 359 | ITensorPack pack; |
| 360 | pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0); |
| 361 | pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1); |
| 362 | pack.add_tensor(TensorType::ACL_DST, _impl->dst); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 363 | |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 364 | _impl->op->run(pack); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | struct CLElementwiseMin::Impl |
| 368 | { |
| 369 | const ICLTensor *src_0{ nullptr }; |
| 370 | const ICLTensor *src_1{ nullptr }; |
| 371 | ICLTensor *dst{ nullptr }; |
| 372 | std::unique_ptr<experimental::CLElementwiseMin> op{ nullptr }; |
| 373 | }; |
| 374 | |
| 375 | CLElementwiseMin::CLElementwiseMin() |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 376 | : _impl(std::make_unique<Impl>()) |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 377 | { |
| 378 | } |
| 379 | CLElementwiseMin::CLElementwiseMin(CLElementwiseMin &&) = default; |
| 380 | CLElementwiseMin &CLElementwiseMin::operator=(CLElementwiseMin &&) = default; |
| 381 | CLElementwiseMin::~CLElementwiseMin() = default; |
| 382 | |
| 383 | void CLElementwiseMin::configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info) |
| 384 | { |
| 385 | configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, act_info); |
| 386 | } |
| 387 | |
| 388 | void CLElementwiseMin::configure(const CLCompileContext &compile_context, ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info) |
| 389 | { |
| 390 | _impl->src_0 = input1; |
| 391 | _impl->src_1 = input2; |
| 392 | _impl->dst = output; |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 393 | _impl->op = std::make_unique<experimental::CLElementwiseMin>(); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 394 | _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), act_info); |
| 395 | } |
| 396 | |
| 397 | Status CLElementwiseMin::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info) |
| 398 | { |
| 399 | return experimental::CLElementwiseMin::validate(input1, input2, output, act_info); |
| 400 | } |
| 401 | |
| 402 | void CLElementwiseMin::run() |
| 403 | { |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 404 | ITensorPack pack; |
| 405 | pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0); |
| 406 | pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1); |
| 407 | pack.add_tensor(TensorType::ACL_DST, _impl->dst); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 408 | |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 409 | _impl->op->run(pack); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 410 | } |
| 411 | |
| 412 | struct CLElementwiseSquaredDiff::Impl |
| 413 | { |
| 414 | const ICLTensor *src_0{ nullptr }; |
| 415 | const ICLTensor *src_1{ nullptr }; |
| 416 | ICLTensor *dst{ nullptr }; |
| 417 | std::unique_ptr<experimental::CLElementwiseSquaredDiff> op{ nullptr }; |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 418 | }; |
| 419 | |
| 420 | CLElementwiseSquaredDiff::CLElementwiseSquaredDiff() |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 421 | : _impl(std::make_unique<Impl>()) |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 422 | { |
| 423 | } |
| 424 | CLElementwiseSquaredDiff::CLElementwiseSquaredDiff(CLElementwiseSquaredDiff &&) = default; |
| 425 | CLElementwiseSquaredDiff &CLElementwiseSquaredDiff::operator=(CLElementwiseSquaredDiff &&) = default; |
| 426 | CLElementwiseSquaredDiff::~CLElementwiseSquaredDiff() = default; |
| 427 | |
| 428 | void CLElementwiseSquaredDiff::configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info) |
| 429 | { |
| 430 | configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, act_info); |
| 431 | } |
| 432 | |
| 433 | void CLElementwiseSquaredDiff::configure(const CLCompileContext &compile_context, ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info) |
| 434 | { |
| 435 | _impl->src_0 = input1; |
| 436 | _impl->src_1 = input2; |
| 437 | _impl->dst = output; |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 438 | _impl->op = std::make_unique<experimental::CLElementwiseSquaredDiff>(); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 439 | _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), act_info); |
| 440 | } |
| 441 | |
| 442 | Status CLElementwiseSquaredDiff::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info) |
| 443 | { |
| 444 | return experimental::CLElementwiseSquaredDiff::validate(input1, input2, output, act_info); |
| 445 | } |
| 446 | |
| 447 | void CLElementwiseSquaredDiff::run() |
| 448 | { |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 449 | ITensorPack pack; |
| 450 | pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0); |
| 451 | pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1); |
| 452 | pack.add_tensor(TensorType::ACL_DST, _impl->dst); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 453 | |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 454 | _impl->op->run(pack); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 455 | } |
| 456 | |
| 457 | struct CLElementwisePower::Impl |
| 458 | { |
| 459 | const ICLTensor *src_0{ nullptr }; |
| 460 | const ICLTensor *src_1{ nullptr }; |
| 461 | ICLTensor *dst{ nullptr }; |
| 462 | std::unique_ptr<experimental::CLElementwisePower> op{ nullptr }; |
| 463 | }; |
| 464 | |
| 465 | CLElementwisePower::CLElementwisePower() |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 466 | : _impl(std::make_unique<Impl>()) |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 467 | { |
| 468 | } |
| 469 | CLElementwisePower::CLElementwisePower(CLElementwisePower &&) = default; |
| 470 | CLElementwisePower &CLElementwisePower::operator=(CLElementwisePower &&) = default; |
| 471 | CLElementwisePower::~CLElementwisePower() = default; |
| 472 | |
| 473 | void CLElementwisePower::configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info) |
| 474 | { |
| 475 | configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, act_info); |
| 476 | } |
| 477 | |
| 478 | void CLElementwisePower::configure(const CLCompileContext &compile_context, ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info) |
| 479 | { |
| 480 | _impl->src_0 = input1; |
| 481 | _impl->src_1 = input2; |
| 482 | _impl->dst = output; |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 483 | _impl->op = std::make_unique<experimental::CLElementwisePower>(); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 484 | _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), act_info); |
| 485 | } |
| 486 | |
| 487 | Status CLElementwisePower::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info) |
| 488 | { |
| 489 | return experimental::CLElementwisePower::validate(input1, input2, output, act_info); |
| 490 | } |
| 491 | |
| 492 | void CLElementwisePower::run() |
| 493 | { |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 494 | ITensorPack pack; |
| 495 | pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0); |
| 496 | pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1); |
| 497 | pack.add_tensor(TensorType::ACL_DST, _impl->dst); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 498 | |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 499 | _impl->op->run(pack); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 500 | } |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 501 | } // namespace arm_compute |