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