blob: d9529f0b7ffc62c1270acbae3d35c1b6bb61e724 [file] [log] [blame]
giuros01164a2722018-11-20 18:34:46 +00001/*
Michele Di Giorgio1e0208a2021-01-22 15:42:59 +00002 * Copyright (c) 2018-2021 Arm Limited.
giuros01164a2722018-11-20 18:34:46 +00003 *
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 */
giuros011e6e1b82019-05-14 16:12:53 +010024#include "arm_compute/runtime/CL/functions/CLElementwiseOperations.h"
25
Michele Di Giorgio237be032021-01-25 15:44:02 +000026#include "arm_compute/core/CL/CLKernelLibrary.h"
giuros01164a2722018-11-20 18:34:46 +000027#include "arm_compute/core/CL/ICLTensor.h"
Michele Di Giorgio237be032021-01-25 15:44:02 +000028#include "arm_compute/core/Types.h"
Michele Di Giorgio1e0208a2021-01-22 15:42:59 +000029
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010030#include "src/core/CL/ICLKernel.h"
Georgios Pinitas7891a732021-08-20 21:39:25 +010031#include "src/gpu/cl/operators/ClAdd.h"
32#include "src/gpu/cl/operators/ClElementwiseOperations.h"
33#include "src/gpu/cl/operators/ClSub.h"
giuros01164a2722018-11-20 18:34:46 +000034
giuros01164a2722018-11-20 18:34:46 +000035namespace arm_compute
36{
Michalis Spyrouad7515d2020-07-24 00:02:23 +010037struct CLArithmeticAddition::Impl
38{
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010039 const ICLTensor *src_0{nullptr};
40 const ICLTensor *src_1{nullptr};
41 ICLTensor *dst{nullptr};
42 std::unique_ptr<opencl::ClAdd> op{nullptr};
Michalis Spyrouad7515d2020-07-24 00:02:23 +010043};
44
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010045CLArithmeticAddition::CLArithmeticAddition() : _impl(std::make_unique<Impl>())
Michalis Spyrouad7515d2020-07-24 00:02:23 +010046{
47}
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010048CLArithmeticAddition::CLArithmeticAddition(CLArithmeticAddition &&) = default;
Michalis Spyrouad7515d2020-07-24 00:02:23 +010049CLArithmeticAddition &CLArithmeticAddition::operator=(CLArithmeticAddition &&) = default;
50CLArithmeticAddition::~CLArithmeticAddition() = default;
51
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010052void CLArithmeticAddition::configure(
53 ICLTensor *input1, ICLTensor *input2, ICLTensor *output, ConvertPolicy policy, const ActivationLayerInfo &act_info)
Michalis Spyrouad7515d2020-07-24 00:02:23 +010054{
55 configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, policy, act_info);
56}
57
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010058void CLArithmeticAddition::configure(const CLCompileContext &compile_context,
59 const ICLTensor *input1,
60 const ICLTensor *input2,
61 ICLTensor *output,
62 ConvertPolicy policy,
Michalis Spyrouad7515d2020-07-24 00:02:23 +010063 const ActivationLayerInfo &act_info)
64{
65 _impl->src_0 = input1;
66 _impl->src_1 = input2;
67 _impl->dst = output;
Michele Di Giorgio1e0208a2021-01-22 15:42:59 +000068 _impl->op = std::make_unique<opencl::ClAdd>();
Michalis Spyrouad7515d2020-07-24 00:02:23 +010069 _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), policy, act_info);
70}
71
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010072Status CLArithmeticAddition::validate(const ITensorInfo *input1,
73 const ITensorInfo *input2,
74 const ITensorInfo *output,
75 ConvertPolicy policy,
76 const ActivationLayerInfo &act_info)
Michalis Spyrouad7515d2020-07-24 00:02:23 +010077{
Michele Di Giorgio1e0208a2021-01-22 15:42:59 +000078 return opencl::ClAdd::validate(input1, input2, output, policy, act_info);
Michalis Spyrouad7515d2020-07-24 00:02:23 +010079}
80
81void CLArithmeticAddition::run()
82{
Georgios Pinitas0499dff2020-07-31 22:21:38 +010083 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 Spyrouad7515d2020-07-24 00:02:23 +010087
Georgios Pinitas0499dff2020-07-31 22:21:38 +010088 _impl->op->run(pack);
Michalis Spyrouad7515d2020-07-24 00:02:23 +010089}
90
91struct CLArithmeticSubtraction::Impl
92{
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010093 const ICLTensor *src_0{nullptr};
94 const ICLTensor *src_1{nullptr};
95 ICLTensor *dst{nullptr};
96 std::unique_ptr<opencl::ClSub> op{nullptr};
Michalis Spyrouad7515d2020-07-24 00:02:23 +010097};
98
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010099CLArithmeticSubtraction::CLArithmeticSubtraction() : _impl(std::make_unique<Impl>())
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100100{
101}
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100102CLArithmeticSubtraction::CLArithmeticSubtraction(CLArithmeticSubtraction &&) = default;
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100103CLArithmeticSubtraction &CLArithmeticSubtraction::operator=(CLArithmeticSubtraction &&) = default;
104CLArithmeticSubtraction::~CLArithmeticSubtraction() = default;
105
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100106void CLArithmeticSubtraction::configure(const ICLTensor *input1,
107 const ICLTensor *input2,
108 ICLTensor *output,
109 ConvertPolicy policy,
110 const ActivationLayerInfo &act_info)
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100111{
112 configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, policy, act_info);
113}
114
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100115void CLArithmeticSubtraction::configure(const CLCompileContext &compile_context,
116 const ICLTensor *input1,
117 const ICLTensor *input2,
118 ICLTensor *output,
119 ConvertPolicy policy,
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100120 const ActivationLayerInfo &act_info)
121{
122 _impl->src_0 = input1;
123 _impl->src_1 = input2;
124 _impl->dst = output;
Michele Di Giorgio4cfab182021-01-25 11:49:03 +0000125 _impl->op = std::make_unique<opencl::ClSub>();
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100126 _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), policy, act_info);
127}
128
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100129Status CLArithmeticSubtraction::validate(const ITensorInfo *input1,
130 const ITensorInfo *input2,
131 const ITensorInfo *output,
132 ConvertPolicy policy,
133 const ActivationLayerInfo &act_info)
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100134{
Michele Di Giorgio4cfab182021-01-25 11:49:03 +0000135 return opencl::ClSub::validate(input1, input2, output, policy, act_info);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100136}
137
138void CLArithmeticSubtraction::run()
139{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100140 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 Spyrouad7515d2020-07-24 00:02:23 +0100144
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100145 _impl->op->run(pack);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100146}
147
148struct CLArithmeticDivision::Impl
149{
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100150 const ICLTensor *src_0{nullptr};
151 const ICLTensor *src_1{nullptr};
152 ICLTensor *dst{nullptr};
153 std::unique_ptr<opencl::ClElementwiseDivision> op{nullptr};
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100154};
155
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100156CLArithmeticDivision::CLArithmeticDivision() : _impl(std::make_unique<Impl>())
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100157{
158}
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100159CLArithmeticDivision::CLArithmeticDivision(CLArithmeticDivision &&) = default;
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100160CLArithmeticDivision &CLArithmeticDivision::operator=(CLArithmeticDivision &&) = default;
161CLArithmeticDivision::~CLArithmeticDivision() = default;
162
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100163void CLArithmeticDivision::configure(ICLTensor *input1,
164 ICLTensor *input2,
165 ICLTensor *output,
166 const ActivationLayerInfo &act_info)
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100167{
168 configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, act_info);
169}
170
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100171void CLArithmeticDivision::configure(const CLCompileContext &compile_context,
172 const ICLTensor *input1,
173 const ICLTensor *input2,
174 ICLTensor *output,
175 const ActivationLayerInfo &act_info)
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100176{
177 _impl->src_0 = input1;
178 _impl->src_1 = input2;
179 _impl->dst = output;
Michele Di Giorgio237be032021-01-25 15:44:02 +0000180 _impl->op = std::make_unique<opencl::ClElementwiseDivision>();
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100181 _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), act_info);
182}
183
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100184Status CLArithmeticDivision::validate(const ITensorInfo *input1,
185 const ITensorInfo *input2,
186 const ITensorInfo *output,
187 const ActivationLayerInfo &act_info)
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100188{
Michele Di Giorgio237be032021-01-25 15:44:02 +0000189 return opencl::ClElementwiseDivision::validate(input1, input2, output, act_info);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100190}
191
192void CLArithmeticDivision::run()
193{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100194 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 Spyrouad7515d2020-07-24 00:02:23 +0100198
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100199 _impl->op->run(pack);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100200}
201
202struct CLElementwiseMax::Impl
203{
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100204 const ICLTensor *src_0{nullptr};
205 const ICLTensor *src_1{nullptr};
206 ICLTensor *dst{nullptr};
207 std::unique_ptr<opencl::ClElementwiseMax> op{nullptr};
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100208};
209
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100210CLElementwiseMax::CLElementwiseMax() : _impl(std::make_unique<Impl>())
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100211{
212}
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100213CLElementwiseMax::CLElementwiseMax(CLElementwiseMax &&) = default;
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100214CLElementwiseMax &CLElementwiseMax::operator=(CLElementwiseMax &&) = default;
215CLElementwiseMax::~CLElementwiseMax() = default;
216
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100217void CLElementwiseMax::configure(ICLTensor *input1,
218 ICLTensor *input2,
219 ICLTensor *output,
220 const ActivationLayerInfo &act_info)
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100221{
222 configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, act_info);
223}
224
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100225void CLElementwiseMax::configure(const CLCompileContext &compile_context,
226 ICLTensor *input1,
227 ICLTensor *input2,
228 ICLTensor *output,
229 const ActivationLayerInfo &act_info)
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100230{
231 _impl->src_0 = input1;
232 _impl->src_1 = input2;
233 _impl->dst = output;
Michele Di Giorgio237be032021-01-25 15:44:02 +0000234 _impl->op = std::make_unique<opencl::ClElementwiseMax>();
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100235 _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), act_info);
236}
237
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100238Status CLElementwiseMax::validate(const ITensorInfo *input1,
239 const ITensorInfo *input2,
240 const ITensorInfo *output,
241 const ActivationLayerInfo &act_info)
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100242{
Michele Di Giorgio237be032021-01-25 15:44:02 +0000243 return opencl::ClElementwiseMax::validate(input1, input2, output, act_info);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100244}
245
246void CLElementwiseMax::run()
247{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100248 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 Spyrouad7515d2020-07-24 00:02:23 +0100252
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100253 _impl->op->run(pack);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100254}
255
256struct CLElementwiseMin::Impl
257{
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100258 const ICLTensor *src_0{nullptr};
259 const ICLTensor *src_1{nullptr};
260 ICLTensor *dst{nullptr};
261 std::unique_ptr<opencl::ClElementwiseMin> op{nullptr};
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100262};
263
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100264CLElementwiseMin::CLElementwiseMin() : _impl(std::make_unique<Impl>())
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100265{
266}
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100267CLElementwiseMin::CLElementwiseMin(CLElementwiseMin &&) = default;
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100268CLElementwiseMin &CLElementwiseMin::operator=(CLElementwiseMin &&) = default;
269CLElementwiseMin::~CLElementwiseMin() = default;
270
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100271void CLElementwiseMin::configure(ICLTensor *input1,
272 ICLTensor *input2,
273 ICLTensor *output,
274 const ActivationLayerInfo &act_info)
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100275{
276 configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, act_info);
277}
278
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100279void CLElementwiseMin::configure(const CLCompileContext &compile_context,
280 ICLTensor *input1,
281 ICLTensor *input2,
282 ICLTensor *output,
283 const ActivationLayerInfo &act_info)
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100284{
285 _impl->src_0 = input1;
286 _impl->src_1 = input2;
287 _impl->dst = output;
Michele Di Giorgio237be032021-01-25 15:44:02 +0000288 _impl->op = std::make_unique<opencl::ClElementwiseMin>();
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100289 _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), act_info);
290}
291
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100292Status CLElementwiseMin::validate(const ITensorInfo *input1,
293 const ITensorInfo *input2,
294 const ITensorInfo *output,
295 const ActivationLayerInfo &act_info)
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100296{
Michele Di Giorgio237be032021-01-25 15:44:02 +0000297 return opencl::ClElementwiseMin::validate(input1, input2, output, act_info);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100298}
299
300void CLElementwiseMin::run()
301{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100302 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 Spyrouad7515d2020-07-24 00:02:23 +0100306
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100307 _impl->op->run(pack);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100308}
309
310struct CLElementwiseSquaredDiff::Impl
311{
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100312 const ICLTensor *src_0{nullptr};
313 const ICLTensor *src_1{nullptr};
314 ICLTensor *dst{nullptr};
315 std::unique_ptr<opencl::ClElementwiseSquaredDiff> op{nullptr};
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100316};
317
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100318CLElementwiseSquaredDiff::CLElementwiseSquaredDiff() : _impl(std::make_unique<Impl>())
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100319{
320}
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100321CLElementwiseSquaredDiff::CLElementwiseSquaredDiff(CLElementwiseSquaredDiff &&) = default;
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100322CLElementwiseSquaredDiff &CLElementwiseSquaredDiff::operator=(CLElementwiseSquaredDiff &&) = default;
323CLElementwiseSquaredDiff::~CLElementwiseSquaredDiff() = default;
324
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100325void CLElementwiseSquaredDiff::configure(ICLTensor *input1,
326 ICLTensor *input2,
327 ICLTensor *output,
328 const ActivationLayerInfo &act_info)
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100329{
330 configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, act_info);
331}
332
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100333void CLElementwiseSquaredDiff::configure(const CLCompileContext &compile_context,
334 ICLTensor *input1,
335 ICLTensor *input2,
336 ICLTensor *output,
337 const ActivationLayerInfo &act_info)
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100338{
339 _impl->src_0 = input1;
340 _impl->src_1 = input2;
341 _impl->dst = output;
Michele Di Giorgio237be032021-01-25 15:44:02 +0000342 _impl->op = std::make_unique<opencl::ClElementwiseSquaredDiff>();
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100343 _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), act_info);
344}
345
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100346Status CLElementwiseSquaredDiff::validate(const ITensorInfo *input1,
347 const ITensorInfo *input2,
348 const ITensorInfo *output,
349 const ActivationLayerInfo &act_info)
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100350{
Michele Di Giorgio237be032021-01-25 15:44:02 +0000351 return opencl::ClElementwiseSquaredDiff::validate(input1, input2, output, act_info);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100352}
353
354void CLElementwiseSquaredDiff::run()
355{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100356 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 Spyrouad7515d2020-07-24 00:02:23 +0100360
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100361 _impl->op->run(pack);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100362}
363
364struct CLElementwisePower::Impl
365{
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100366 const ICLTensor *src_0{nullptr};
367 const ICLTensor *src_1{nullptr};
368 ICLTensor *dst{nullptr};
369 std::unique_ptr<opencl::ClElementwisePower> op{nullptr};
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100370};
371
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100372CLElementwisePower::CLElementwisePower() : _impl(std::make_unique<Impl>())
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100373{
374}
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100375CLElementwisePower::CLElementwisePower(CLElementwisePower &&) = default;
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100376CLElementwisePower &CLElementwisePower::operator=(CLElementwisePower &&) = default;
377CLElementwisePower::~CLElementwisePower() = default;
378
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100379void CLElementwisePower::configure(ICLTensor *input1,
380 ICLTensor *input2,
381 ICLTensor *output,
382 const ActivationLayerInfo &act_info)
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100383{
384 configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, act_info);
385}
386
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100387void CLElementwisePower::configure(const CLCompileContext &compile_context,
388 ICLTensor *input1,
389 ICLTensor *input2,
390 ICLTensor *output,
391 const ActivationLayerInfo &act_info)
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100392{
393 _impl->src_0 = input1;
394 _impl->src_1 = input2;
395 _impl->dst = output;
Michele Di Giorgio237be032021-01-25 15:44:02 +0000396 _impl->op = std::make_unique<opencl::ClElementwisePower>();
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100397 _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), act_info);
398}
399
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100400Status CLElementwisePower::validate(const ITensorInfo *input1,
401 const ITensorInfo *input2,
402 const ITensorInfo *output,
403 const ActivationLayerInfo &act_info)
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100404{
Michele Di Giorgio237be032021-01-25 15:44:02 +0000405 return opencl::ClElementwisePower::validate(input1, input2, output, act_info);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100406}
407
408void CLElementwisePower::run()
409{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100410 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 Spyrouad7515d2020-07-24 00:02:23 +0100414
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100415 _impl->op->run(pack);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100416}
giuros01164a2722018-11-20 18:34:46 +0000417} // namespace arm_compute