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