blob: 638990e472c1af2b8feabc7cc22061befde7248a [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
giuros01164a2722018-11-20 18:34:46 +000026#include "arm_compute/core/CL/ICLTensor.h"
Michalis Spyrouad7515d2020-07-24 00:02:23 +010027#include "arm_compute/runtime/CL/CLScheduler.h"
Michele Di Giorgio1e0208a2021-01-22 15:42:59 +000028#include "src/core/gpu/cl/kernels/ClElementwiseKernel.h"
29
30#include "src/runtime/gpu/cl/operators/ClAdd.h"
giuros01164a2722018-11-20 18:34:46 +000031
32#include <utility>
33
34namespace arm_compute
35{
Michalis Spyrouad7515d2020-07-24 00:02:23 +010036namespace experimental
giuros01164a2722018-11-20 18:34:46 +000037{
Michalis Spyrouad7515d2020-07-24 00:02:23 +010038CLArithmeticSubtraction::CLArithmeticSubtraction()
Michalis Spyrouad7515d2020-07-24 00:02:23 +010039{
40}
41void CLArithmeticSubtraction::configure(const CLCompileContext &compile_context, ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, ConvertPolicy policy,
42 const ActivationLayerInfo &act_info)
Manuel Bottini2b84be52020-04-08 10:15:51 +010043{
Michele Di Giorgio1e0208a2021-01-22 15:42:59 +000044 auto k = std::make_unique<arm_compute::opencl::kernels::ClSaturatedArithmeticKernel>();
Manuel Bottini2b84be52020-04-08 10:15:51 +010045 k->configure(compile_context, ArithmeticOperation::SUB, input1, input2, output, policy, act_info);
giuros01164a2722018-11-20 18:34:46 +000046 _kernel = std::move(k);
giuros01164a2722018-11-20 18:34:46 +000047}
48
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000049Status CLArithmeticSubtraction::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ConvertPolicy policy, const ActivationLayerInfo &act_info)
giuros01164a2722018-11-20 18:34:46 +000050{
51 ARM_COMPUTE_UNUSED(policy);
Michele Di Giorgio1e0208a2021-01-22 15:42:59 +000052 return arm_compute::opencl::kernels::ClSaturatedArithmeticKernel::validate(ArithmeticOperation::SUB, input1, input2, output, policy, act_info);
giuros01164a2722018-11-20 18:34:46 +000053}
54
Georgios Pinitas0499dff2020-07-31 22:21:38 +010055void CLArithmeticSubtraction::run(ITensorPack &tensors)
giuros01164a2722018-11-20 18:34:46 +000056{
Georgios Pinitas0499dff2020-07-31 22:21:38 +010057 ICLOperator::run(tensors);
Manuel Bottini2b84be52020-04-08 10:15:51 +010058}
59
Michalis Spyrouad7515d2020-07-24 00:02:23 +010060CLArithmeticDivision::CLArithmeticDivision()
Michalis Spyrouad7515d2020-07-24 00:02:23 +010061{
62}
63
64void CLArithmeticDivision::configure(const CLCompileContext &compile_context, ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, const ActivationLayerInfo &act_info)
Manuel Bottini2b84be52020-04-08 10:15:51 +010065{
Michele Di Giorgio1e0208a2021-01-22 15:42:59 +000066 auto k = std::make_unique<arm_compute::opencl::kernels::ClArithmeticKernel>();
Manuel Bottini2b84be52020-04-08 10:15:51 +010067 k->configure(compile_context, ArithmeticOperation::DIV, input1, input2, output, act_info);
giuros01164a2722018-11-20 18:34:46 +000068 _kernel = std::move(k);
giuros01164a2722018-11-20 18:34:46 +000069}
70
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000071Status CLArithmeticDivision::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info)
giuros01164a2722018-11-20 18:34:46 +000072{
Michele Di Giorgio1e0208a2021-01-22 15:42:59 +000073 return arm_compute::opencl::kernels::ClArithmeticKernel::validate(ArithmeticOperation::DIV, input1, input2, output, act_info);
giuros01164a2722018-11-20 18:34:46 +000074}
75
Georgios Pinitas0499dff2020-07-31 22:21:38 +010076void CLArithmeticDivision::run(ITensorPack &tensors)
giuros01164a2722018-11-20 18:34:46 +000077{
Georgios Pinitas0499dff2020-07-31 22:21:38 +010078 ICLOperator::run(tensors);
Manuel Bottini2b84be52020-04-08 10:15:51 +010079}
80
Michalis Spyrouad7515d2020-07-24 00:02:23 +010081CLElementwiseMax::CLElementwiseMax()
Michalis Spyrouad7515d2020-07-24 00:02:23 +010082{
83}
84
85void CLElementwiseMax::configure(const CLCompileContext &compile_context, ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, const ActivationLayerInfo &act_info)
Manuel Bottini2b84be52020-04-08 10:15:51 +010086{
Michele Di Giorgio1e0208a2021-01-22 15:42:59 +000087 auto k = std::make_unique<arm_compute::opencl::kernels::ClArithmeticKernel>();
Manuel Bottini2b84be52020-04-08 10:15:51 +010088 k->configure(compile_context, ArithmeticOperation::MAX, input1, input2, output, act_info);
giuros01164a2722018-11-20 18:34:46 +000089 _kernel = std::move(k);
giuros01164a2722018-11-20 18:34:46 +000090}
91
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000092Status CLElementwiseMax::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info)
giuros01164a2722018-11-20 18:34:46 +000093{
Michele Di Giorgio1e0208a2021-01-22 15:42:59 +000094 return arm_compute::opencl::kernels::ClArithmeticKernel::validate(ArithmeticOperation::MAX, input1, input2, output, act_info);
giuros01164a2722018-11-20 18:34:46 +000095}
96
Georgios Pinitas0499dff2020-07-31 22:21:38 +010097void CLElementwiseMax::run(ITensorPack &tensors)
giuros01164a2722018-11-20 18:34:46 +000098{
Georgios Pinitas0499dff2020-07-31 22:21:38 +010099 ICLOperator::run(tensors);
Manuel Bottini2b84be52020-04-08 10:15:51 +0100100}
101
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100102CLElementwiseMin::CLElementwiseMin()
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100103{
104}
105
106void CLElementwiseMin::configure(const CLCompileContext &compile_context, ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, const ActivationLayerInfo &act_info)
Manuel Bottini2b84be52020-04-08 10:15:51 +0100107{
Michele Di Giorgio1e0208a2021-01-22 15:42:59 +0000108 auto k = std::make_unique<arm_compute::opencl::kernels::ClArithmeticKernel>();
Manuel Bottini2b84be52020-04-08 10:15:51 +0100109 k->configure(compile_context, ArithmeticOperation::MIN, input1, input2, output, act_info);
giuros01164a2722018-11-20 18:34:46 +0000110 _kernel = std::move(k);
giuros01164a2722018-11-20 18:34:46 +0000111}
112
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000113Status CLElementwiseMin::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info)
giuros01164a2722018-11-20 18:34:46 +0000114{
Michele Di Giorgio1e0208a2021-01-22 15:42:59 +0000115 return arm_compute::opencl::kernels::ClArithmeticKernel::validate(ArithmeticOperation::MIN, input1, input2, output, act_info);
giuros01164a2722018-11-20 18:34:46 +0000116}
117
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100118void CLElementwiseMin::run(ITensorPack &tensors)
giuros01164a2722018-11-20 18:34:46 +0000119{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100120 ICLOperator::run(tensors);
Manuel Bottini2b84be52020-04-08 10:15:51 +0100121}
122
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100123CLElementwiseSquaredDiff::CLElementwiseSquaredDiff()
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100124{
125}
126
127void CLElementwiseSquaredDiff::configure(const CLCompileContext &compile_context, ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, const ActivationLayerInfo &act_info)
Manuel Bottini2b84be52020-04-08 10:15:51 +0100128{
Michele Di Giorgio1e0208a2021-01-22 15:42:59 +0000129 auto k = std::make_unique<arm_compute::opencl::kernels::ClArithmeticKernel>();
Manuel Bottini2b84be52020-04-08 10:15:51 +0100130 k->configure(compile_context, ArithmeticOperation::SQUARED_DIFF, input1, input2, output, act_info);
giuros01164a2722018-11-20 18:34:46 +0000131 _kernel = std::move(k);
giuros01164a2722018-11-20 18:34:46 +0000132}
133
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000134Status CLElementwiseSquaredDiff::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info)
giuros01164a2722018-11-20 18:34:46 +0000135{
Michele Di Giorgio1e0208a2021-01-22 15:42:59 +0000136 return arm_compute::opencl::kernels::ClArithmeticKernel::validate(ArithmeticOperation::SQUARED_DIFF, input1, input2, output, act_info);
giuros01164a2722018-11-20 18:34:46 +0000137}
Usama Arif52c54f62019-05-14 10:22:36 +0100138
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100139void CLElementwiseSquaredDiff::run(ITensorPack &tensors)
Usama Arif52c54f62019-05-14 10:22:36 +0100140{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100141 ICLOperator::run(tensors);
Manuel Bottini2b84be52020-04-08 10:15:51 +0100142}
143
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100144CLElementwisePower::CLElementwisePower()
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100145{
146}
147
148void CLElementwisePower::configure(const CLCompileContext &compile_context, ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, const ActivationLayerInfo &act_info)
Manuel Bottini2b84be52020-04-08 10:15:51 +0100149{
Michele Di Giorgio1e0208a2021-01-22 15:42:59 +0000150 auto k = std::make_unique<arm_compute::opencl::kernels::ClArithmeticKernel>();
Manuel Bottini2b84be52020-04-08 10:15:51 +0100151 k->configure(compile_context, ArithmeticOperation::POWER, input1, input2, output, act_info);
Usama Arif52c54f62019-05-14 10:22:36 +0100152 _kernel = std::move(k);
Usama Arif52c54f62019-05-14 10:22:36 +0100153}
154
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000155Status CLElementwisePower::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info)
Usama Arif52c54f62019-05-14 10:22:36 +0100156{
Michele Di Giorgio1e0208a2021-01-22 15:42:59 +0000157 return arm_compute::opencl::kernels::ClArithmeticKernel::validate(ArithmeticOperation::POWER, input1, input2, output, act_info);
Usama Arif52c54f62019-05-14 10:22:36 +0100158}
159
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100160void CLElementwisePower::run(ITensorPack &tensors)
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100161{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100162 ICLOperator::run(tensors);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100163}
164} // namespace experimental
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100165struct CLArithmeticAddition::Impl
166{
Michele Di Giorgio1e0208a2021-01-22 15:42:59 +0000167 const ICLTensor *src_0{ nullptr };
168 const ICLTensor *src_1{ nullptr };
169 ICLTensor *dst{ nullptr };
170 std::unique_ptr<opencl::ClAdd> op{ nullptr };
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100171};
172
173CLArithmeticAddition::CLArithmeticAddition()
Georgios Pinitas40f51a62020-11-21 03:04:18 +0000174 : _impl(std::make_unique<Impl>())
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100175{
176}
177CLArithmeticAddition::CLArithmeticAddition(CLArithmeticAddition &&) = default;
178CLArithmeticAddition &CLArithmeticAddition::operator=(CLArithmeticAddition &&) = default;
179CLArithmeticAddition::~CLArithmeticAddition() = default;
180
181void 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
186void 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 Giorgio1e0208a2021-01-22 15:42:59 +0000192 _impl->op = std::make_unique<opencl::ClAdd>();
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100193 _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), policy, act_info);
194}
195
196Status CLArithmeticAddition::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ConvertPolicy policy, const ActivationLayerInfo &act_info)
197{
Michele Di Giorgio1e0208a2021-01-22 15:42:59 +0000198 return opencl::ClAdd::validate(input1, input2, output, policy, act_info);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100199}
200
201void CLArithmeticAddition::run()
202{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100203 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 Spyrouad7515d2020-07-24 00:02:23 +0100207
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100208 _impl->op->run(pack);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100209}
210
211struct 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
219CLArithmeticSubtraction::CLArithmeticSubtraction()
Georgios Pinitas40f51a62020-11-21 03:04:18 +0000220 : _impl(std::make_unique<Impl>())
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100221{
222}
223CLArithmeticSubtraction::CLArithmeticSubtraction(CLArithmeticSubtraction &&) = default;
224CLArithmeticSubtraction &CLArithmeticSubtraction::operator=(CLArithmeticSubtraction &&) = default;
225CLArithmeticSubtraction::~CLArithmeticSubtraction() = default;
226
227void 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
232void 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 Pinitas40f51a62020-11-21 03:04:18 +0000238 _impl->op = std::make_unique<experimental::CLArithmeticSubtraction>();
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100239 _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), policy, act_info);
240}
241
242Status 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
247void CLArithmeticSubtraction::run()
248{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100249 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 Spyrouad7515d2020-07-24 00:02:23 +0100253
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100254 _impl->op->run(pack);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100255}
256
257struct 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
265CLArithmeticDivision::CLArithmeticDivision()
Georgios Pinitas40f51a62020-11-21 03:04:18 +0000266 : _impl(std::make_unique<Impl>())
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100267{
268}
269CLArithmeticDivision::CLArithmeticDivision(CLArithmeticDivision &&) = default;
270CLArithmeticDivision &CLArithmeticDivision::operator=(CLArithmeticDivision &&) = default;
271CLArithmeticDivision::~CLArithmeticDivision() = default;
272
273void 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
278void 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 Pinitas40f51a62020-11-21 03:04:18 +0000283 _impl->op = std::make_unique<experimental::CLArithmeticDivision>();
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100284 _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), act_info);
285}
286
287Status 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
292void CLArithmeticDivision::run()
293{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100294 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 Spyrouad7515d2020-07-24 00:02:23 +0100298
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100299 _impl->op->run(pack);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100300}
301
302struct 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
310CLElementwiseMax::CLElementwiseMax()
Georgios Pinitas40f51a62020-11-21 03:04:18 +0000311 : _impl(std::make_unique<Impl>())
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100312{
313}
314CLElementwiseMax::CLElementwiseMax(CLElementwiseMax &&) = default;
315CLElementwiseMax &CLElementwiseMax::operator=(CLElementwiseMax &&) = default;
316CLElementwiseMax::~CLElementwiseMax() = default;
317
318void 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
323void 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 Pinitas40f51a62020-11-21 03:04:18 +0000328 _impl->op = std::make_unique<experimental::CLElementwiseMax>();
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100329 _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), act_info);
330}
331
332Status 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
337void CLElementwiseMax::run()
338{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100339 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 Spyrouad7515d2020-07-24 00:02:23 +0100343
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100344 _impl->op->run(pack);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100345}
346
347struct 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
355CLElementwiseMin::CLElementwiseMin()
Georgios Pinitas40f51a62020-11-21 03:04:18 +0000356 : _impl(std::make_unique<Impl>())
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100357{
358}
359CLElementwiseMin::CLElementwiseMin(CLElementwiseMin &&) = default;
360CLElementwiseMin &CLElementwiseMin::operator=(CLElementwiseMin &&) = default;
361CLElementwiseMin::~CLElementwiseMin() = default;
362
363void 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
368void 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 Pinitas40f51a62020-11-21 03:04:18 +0000373 _impl->op = std::make_unique<experimental::CLElementwiseMin>();
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100374 _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), act_info);
375}
376
377Status 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
382void CLElementwiseMin::run()
383{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100384 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 Spyrouad7515d2020-07-24 00:02:23 +0100388
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100389 _impl->op->run(pack);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100390}
391
392struct 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 Spyrouad7515d2020-07-24 00:02:23 +0100398};
399
400CLElementwiseSquaredDiff::CLElementwiseSquaredDiff()
Georgios Pinitas40f51a62020-11-21 03:04:18 +0000401 : _impl(std::make_unique<Impl>())
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100402{
403}
404CLElementwiseSquaredDiff::CLElementwiseSquaredDiff(CLElementwiseSquaredDiff &&) = default;
405CLElementwiseSquaredDiff &CLElementwiseSquaredDiff::operator=(CLElementwiseSquaredDiff &&) = default;
406CLElementwiseSquaredDiff::~CLElementwiseSquaredDiff() = default;
407
408void 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
413void 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 Pinitas40f51a62020-11-21 03:04:18 +0000418 _impl->op = std::make_unique<experimental::CLElementwiseSquaredDiff>();
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100419 _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), act_info);
420}
421
422Status 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
427void CLElementwiseSquaredDiff::run()
428{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100429 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 Spyrouad7515d2020-07-24 00:02:23 +0100433
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100434 _impl->op->run(pack);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100435}
436
437struct 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
445CLElementwisePower::CLElementwisePower()
Georgios Pinitas40f51a62020-11-21 03:04:18 +0000446 : _impl(std::make_unique<Impl>())
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100447{
448}
449CLElementwisePower::CLElementwisePower(CLElementwisePower &&) = default;
450CLElementwisePower &CLElementwisePower::operator=(CLElementwisePower &&) = default;
451CLElementwisePower::~CLElementwisePower() = default;
452
453void 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
458void 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 Pinitas40f51a62020-11-21 03:04:18 +0000463 _impl->op = std::make_unique<experimental::CLElementwisePower>();
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100464 _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), act_info);
465}
466
467Status 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
472void CLElementwisePower::run()
473{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100474 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 Spyrouad7515d2020-07-24 00:02:23 +0100478
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100479 _impl->op->run(pack);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100480}
giuros01164a2722018-11-20 18:34:46 +0000481} // namespace arm_compute