blob: a72e957fe655682c276e92448689b98c6a4018c8 [file] [log] [blame]
giuros01164a2722018-11-20 18:34:46 +00001/*
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01002 * Copyright (c) 2018-2020 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"
Sang-Hoon Parkbef7fa22020-10-21 15:58:54 +010028#include "src/core/CL/kernels/CLElementwiseOperationKernel.h"
giuros01164a2722018-11-20 18:34:46 +000029
30#include <utility>
31
32namespace arm_compute
33{
Michalis Spyrouad7515d2020-07-24 00:02:23 +010034namespace experimental
giuros01164a2722018-11-20 18:34:46 +000035{
Michalis Spyrouad7515d2020-07-24 00:02:23 +010036CLArithmeticAddition::CLArithmeticAddition()
Michalis Spyrouad7515d2020-07-24 00:02:23 +010037{
Manuel Bottini2b84be52020-04-08 10:15:51 +010038}
39
Michalis Spyrouad7515d2020-07-24 00:02:23 +010040void CLArithmeticAddition::configure(const CLCompileContext &compile_context, ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, ConvertPolicy policy, const ActivationLayerInfo &act_info)
Manuel Bottini2b84be52020-04-08 10:15:51 +010041{
Georgios Pinitas40f51a62020-11-21 03:04:18 +000042 auto k = std::make_unique<CLSaturatedArithmeticOperationKernel>();
Manuel Bottini2b84be52020-04-08 10:15:51 +010043 k->configure(compile_context, ArithmeticOperation::ADD, input1, input2, output, policy, act_info);
giuros01164a2722018-11-20 18:34:46 +000044 _kernel = std::move(k);
giuros01164a2722018-11-20 18:34:46 +000045}
46
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000047Status CLArithmeticAddition::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ConvertPolicy policy, const ActivationLayerInfo &act_info)
giuros01164a2722018-11-20 18:34:46 +000048{
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000049 return CLSaturatedArithmeticOperationKernel::validate(ArithmeticOperation::ADD, input1, input2, output, policy, act_info);
giuros01164a2722018-11-20 18:34:46 +000050}
51
Georgios Pinitas0499dff2020-07-31 22:21:38 +010052void CLArithmeticAddition::run(ITensorPack &tensors)
giuros01164a2722018-11-20 18:34:46 +000053{
Georgios Pinitas0499dff2020-07-31 22:21:38 +010054 ICLOperator::run(tensors);
Manuel Bottini2b84be52020-04-08 10:15:51 +010055}
56
Michalis Spyrouad7515d2020-07-24 00:02:23 +010057CLArithmeticSubtraction::CLArithmeticSubtraction()
Michalis Spyrouad7515d2020-07-24 00:02:23 +010058{
59}
60void CLArithmeticSubtraction::configure(const CLCompileContext &compile_context, ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, ConvertPolicy policy,
61 const ActivationLayerInfo &act_info)
Manuel Bottini2b84be52020-04-08 10:15:51 +010062{
Georgios Pinitas40f51a62020-11-21 03:04:18 +000063 auto k = std::make_unique<CLSaturatedArithmeticOperationKernel>();
Manuel Bottini2b84be52020-04-08 10:15:51 +010064 k->configure(compile_context, ArithmeticOperation::SUB, input1, input2, output, policy, act_info);
giuros01164a2722018-11-20 18:34:46 +000065 _kernel = std::move(k);
giuros01164a2722018-11-20 18:34:46 +000066}
67
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000068Status CLArithmeticSubtraction::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ConvertPolicy policy, const ActivationLayerInfo &act_info)
giuros01164a2722018-11-20 18:34:46 +000069{
70 ARM_COMPUTE_UNUSED(policy);
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000071 return CLSaturatedArithmeticOperationKernel::validate(ArithmeticOperation::SUB, input1, input2, output, policy, act_info);
giuros01164a2722018-11-20 18:34:46 +000072}
73
Georgios Pinitas0499dff2020-07-31 22:21:38 +010074void CLArithmeticSubtraction::run(ITensorPack &tensors)
giuros01164a2722018-11-20 18:34:46 +000075{
Georgios Pinitas0499dff2020-07-31 22:21:38 +010076 ICLOperator::run(tensors);
Manuel Bottini2b84be52020-04-08 10:15:51 +010077}
78
Michalis Spyrouad7515d2020-07-24 00:02:23 +010079CLArithmeticDivision::CLArithmeticDivision()
Michalis Spyrouad7515d2020-07-24 00:02:23 +010080{
81}
82
83void CLArithmeticDivision::configure(const CLCompileContext &compile_context, ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, const ActivationLayerInfo &act_info)
Manuel Bottini2b84be52020-04-08 10:15:51 +010084{
Georgios Pinitas40f51a62020-11-21 03:04:18 +000085 auto k = std::make_unique<CLArithmeticOperationKernel>();
Manuel Bottini2b84be52020-04-08 10:15:51 +010086 k->configure(compile_context, ArithmeticOperation::DIV, input1, input2, output, act_info);
giuros01164a2722018-11-20 18:34:46 +000087 _kernel = std::move(k);
giuros01164a2722018-11-20 18:34:46 +000088}
89
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000090Status CLArithmeticDivision::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info)
giuros01164a2722018-11-20 18:34:46 +000091{
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000092 return CLArithmeticOperationKernel::validate(ArithmeticOperation::DIV, input1, input2, output, act_info);
giuros01164a2722018-11-20 18:34:46 +000093}
94
Georgios Pinitas0499dff2020-07-31 22:21:38 +010095void CLArithmeticDivision::run(ITensorPack &tensors)
giuros01164a2722018-11-20 18:34:46 +000096{
Georgios Pinitas0499dff2020-07-31 22:21:38 +010097 ICLOperator::run(tensors);
Manuel Bottini2b84be52020-04-08 10:15:51 +010098}
99
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100100CLElementwiseMax::CLElementwiseMax()
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100101{
102}
103
104void CLElementwiseMax::configure(const CLCompileContext &compile_context, ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, const ActivationLayerInfo &act_info)
Manuel Bottini2b84be52020-04-08 10:15:51 +0100105{
Georgios Pinitas40f51a62020-11-21 03:04:18 +0000106 auto k = std::make_unique<CLArithmeticOperationKernel>();
Manuel Bottini2b84be52020-04-08 10:15:51 +0100107 k->configure(compile_context, ArithmeticOperation::MAX, input1, input2, output, act_info);
giuros01164a2722018-11-20 18:34:46 +0000108 _kernel = std::move(k);
giuros01164a2722018-11-20 18:34:46 +0000109}
110
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000111Status CLElementwiseMax::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info)
giuros01164a2722018-11-20 18:34:46 +0000112{
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000113 return CLArithmeticOperationKernel::validate(ArithmeticOperation::MAX, input1, input2, output, act_info);
giuros01164a2722018-11-20 18:34:46 +0000114}
115
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100116void CLElementwiseMax::run(ITensorPack &tensors)
giuros01164a2722018-11-20 18:34:46 +0000117{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100118 ICLOperator::run(tensors);
Manuel Bottini2b84be52020-04-08 10:15:51 +0100119}
120
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100121CLElementwiseMin::CLElementwiseMin()
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100122{
123}
124
125void CLElementwiseMin::configure(const CLCompileContext &compile_context, ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, const ActivationLayerInfo &act_info)
Manuel Bottini2b84be52020-04-08 10:15:51 +0100126{
Georgios Pinitas40f51a62020-11-21 03:04:18 +0000127 auto k = std::make_unique<CLArithmeticOperationKernel>();
Manuel Bottini2b84be52020-04-08 10:15:51 +0100128 k->configure(compile_context, ArithmeticOperation::MIN, input1, input2, output, act_info);
giuros01164a2722018-11-20 18:34:46 +0000129 _kernel = std::move(k);
giuros01164a2722018-11-20 18:34:46 +0000130}
131
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000132Status CLElementwiseMin::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info)
giuros01164a2722018-11-20 18:34:46 +0000133{
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000134 return CLArithmeticOperationKernel::validate(ArithmeticOperation::MIN, input1, input2, output, act_info);
giuros01164a2722018-11-20 18:34:46 +0000135}
136
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100137void CLElementwiseMin::run(ITensorPack &tensors)
giuros01164a2722018-11-20 18:34:46 +0000138{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100139 ICLOperator::run(tensors);
Manuel Bottini2b84be52020-04-08 10:15:51 +0100140}
141
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100142CLElementwiseSquaredDiff::CLElementwiseSquaredDiff()
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100143{
144}
145
146void CLElementwiseSquaredDiff::configure(const CLCompileContext &compile_context, ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, const ActivationLayerInfo &act_info)
Manuel Bottini2b84be52020-04-08 10:15:51 +0100147{
Georgios Pinitas40f51a62020-11-21 03:04:18 +0000148 auto k = std::make_unique<CLArithmeticOperationKernel>();
Manuel Bottini2b84be52020-04-08 10:15:51 +0100149 k->configure(compile_context, ArithmeticOperation::SQUARED_DIFF, input1, input2, output, act_info);
giuros01164a2722018-11-20 18:34:46 +0000150 _kernel = std::move(k);
giuros01164a2722018-11-20 18:34:46 +0000151}
152
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000153Status CLElementwiseSquaredDiff::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info)
giuros01164a2722018-11-20 18:34:46 +0000154{
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000155 return CLArithmeticOperationKernel::validate(ArithmeticOperation::SQUARED_DIFF, input1, input2, output, act_info);
giuros01164a2722018-11-20 18:34:46 +0000156}
Usama Arif52c54f62019-05-14 10:22:36 +0100157
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100158void CLElementwiseSquaredDiff::run(ITensorPack &tensors)
Usama Arif52c54f62019-05-14 10:22:36 +0100159{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100160 ICLOperator::run(tensors);
Manuel Bottini2b84be52020-04-08 10:15:51 +0100161}
162
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100163CLElementwisePower::CLElementwisePower()
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100164{
165}
166
167void CLElementwisePower::configure(const CLCompileContext &compile_context, ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, const ActivationLayerInfo &act_info)
Manuel Bottini2b84be52020-04-08 10:15:51 +0100168{
Georgios Pinitas40f51a62020-11-21 03:04:18 +0000169 auto k = std::make_unique<CLArithmeticOperationKernel>();
Manuel Bottini2b84be52020-04-08 10:15:51 +0100170 k->configure(compile_context, ArithmeticOperation::POWER, input1, input2, output, act_info);
Usama Arif52c54f62019-05-14 10:22:36 +0100171 _kernel = std::move(k);
Usama Arif52c54f62019-05-14 10:22:36 +0100172}
173
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000174Status CLElementwisePower::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info)
Usama Arif52c54f62019-05-14 10:22:36 +0100175{
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000176 return CLArithmeticOperationKernel::validate(ArithmeticOperation::POWER, input1, input2, output, act_info);
Usama Arif52c54f62019-05-14 10:22:36 +0100177}
178
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100179void CLElementwisePower::run(ITensorPack &tensors)
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100180{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100181 ICLOperator::run(tensors);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100182}
183} // namespace experimental
184
185struct CLArithmeticAddition::Impl
186{
187 const ICLTensor *src_0{ nullptr };
188 const ICLTensor *src_1{ nullptr };
189 ICLTensor *dst{ nullptr };
190 std::unique_ptr<experimental::CLArithmeticAddition> op{ nullptr };
191};
192
193CLArithmeticAddition::CLArithmeticAddition()
Georgios Pinitas40f51a62020-11-21 03:04:18 +0000194 : _impl(std::make_unique<Impl>())
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100195{
196}
197CLArithmeticAddition::CLArithmeticAddition(CLArithmeticAddition &&) = default;
198CLArithmeticAddition &CLArithmeticAddition::operator=(CLArithmeticAddition &&) = default;
199CLArithmeticAddition::~CLArithmeticAddition() = default;
200
201void CLArithmeticAddition::configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, ConvertPolicy policy, const ActivationLayerInfo &act_info)
202{
203 configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, policy, act_info);
204}
205
206void CLArithmeticAddition::configure(const CLCompileContext &compile_context, const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output, ConvertPolicy policy,
207 const ActivationLayerInfo &act_info)
208{
209 _impl->src_0 = input1;
210 _impl->src_1 = input2;
211 _impl->dst = output;
Georgios Pinitas40f51a62020-11-21 03:04:18 +0000212 _impl->op = std::make_unique<experimental::CLArithmeticAddition>();
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100213 _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), policy, act_info);
214}
215
216Status CLArithmeticAddition::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ConvertPolicy policy, const ActivationLayerInfo &act_info)
217{
218 return experimental::CLArithmeticAddition::validate(input1, input2, output, policy, act_info);
219}
220
221void CLArithmeticAddition::run()
222{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100223 ITensorPack pack;
224 pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0);
225 pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1);
226 pack.add_tensor(TensorType::ACL_DST, _impl->dst);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100227
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100228 _impl->op->run(pack);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100229}
230
231struct CLArithmeticSubtraction::Impl
232{
233 const ICLTensor *src_0{ nullptr };
234 const ICLTensor *src_1{ nullptr };
235 ICLTensor *dst{ nullptr };
236 std::unique_ptr<experimental::CLArithmeticSubtraction> op{ nullptr };
237};
238
239CLArithmeticSubtraction::CLArithmeticSubtraction()
Georgios Pinitas40f51a62020-11-21 03:04:18 +0000240 : _impl(std::make_unique<Impl>())
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100241{
242}
243CLArithmeticSubtraction::CLArithmeticSubtraction(CLArithmeticSubtraction &&) = default;
244CLArithmeticSubtraction &CLArithmeticSubtraction::operator=(CLArithmeticSubtraction &&) = default;
245CLArithmeticSubtraction::~CLArithmeticSubtraction() = default;
246
247void CLArithmeticSubtraction::configure(const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output, ConvertPolicy policy, const ActivationLayerInfo &act_info)
248{
249 configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, policy, act_info);
250}
251
252void CLArithmeticSubtraction::configure(const CLCompileContext &compile_context, const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output, ConvertPolicy policy,
253 const ActivationLayerInfo &act_info)
254{
255 _impl->src_0 = input1;
256 _impl->src_1 = input2;
257 _impl->dst = output;
Georgios Pinitas40f51a62020-11-21 03:04:18 +0000258 _impl->op = std::make_unique<experimental::CLArithmeticSubtraction>();
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100259 _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), policy, act_info);
260}
261
262Status CLArithmeticSubtraction::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ConvertPolicy policy, const ActivationLayerInfo &act_info)
263{
264 return experimental::CLArithmeticSubtraction::validate(input1, input2, output, policy, act_info);
265}
266
267void CLArithmeticSubtraction::run()
268{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100269 ITensorPack pack;
270 pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0);
271 pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1);
272 pack.add_tensor(TensorType::ACL_DST, _impl->dst);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100273
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100274 _impl->op->run(pack);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100275}
276
277struct CLArithmeticDivision::Impl
278{
279 const ICLTensor *src_0{ nullptr };
280 const ICLTensor *src_1{ nullptr };
281 ICLTensor *dst{ nullptr };
282 std::unique_ptr<experimental::CLArithmeticDivision> op{ nullptr };
283};
284
285CLArithmeticDivision::CLArithmeticDivision()
Georgios Pinitas40f51a62020-11-21 03:04:18 +0000286 : _impl(std::make_unique<Impl>())
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100287{
288}
289CLArithmeticDivision::CLArithmeticDivision(CLArithmeticDivision &&) = default;
290CLArithmeticDivision &CLArithmeticDivision::operator=(CLArithmeticDivision &&) = default;
291CLArithmeticDivision::~CLArithmeticDivision() = default;
292
293void CLArithmeticDivision::configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info)
294{
295 configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, act_info);
296}
297
298void CLArithmeticDivision::configure(const CLCompileContext &compile_context, const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info)
299{
300 _impl->src_0 = input1;
301 _impl->src_1 = input2;
302 _impl->dst = output;
Georgios Pinitas40f51a62020-11-21 03:04:18 +0000303 _impl->op = std::make_unique<experimental::CLArithmeticDivision>();
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100304 _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), act_info);
305}
306
307Status CLArithmeticDivision::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info)
308{
309 return experimental::CLArithmeticDivision::validate(input1, input2, output, act_info);
310}
311
312void CLArithmeticDivision::run()
313{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100314 ITensorPack pack;
315 pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0);
316 pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1);
317 pack.add_tensor(TensorType::ACL_DST, _impl->dst);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100318
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100319 _impl->op->run(pack);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100320}
321
322struct CLElementwiseMax::Impl
323{
324 const ICLTensor *src_0{ nullptr };
325 const ICLTensor *src_1{ nullptr };
326 ICLTensor *dst{ nullptr };
327 std::unique_ptr<experimental::CLElementwiseMax> op{ nullptr };
328};
329
330CLElementwiseMax::CLElementwiseMax()
Georgios Pinitas40f51a62020-11-21 03:04:18 +0000331 : _impl(std::make_unique<Impl>())
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100332{
333}
334CLElementwiseMax::CLElementwiseMax(CLElementwiseMax &&) = default;
335CLElementwiseMax &CLElementwiseMax::operator=(CLElementwiseMax &&) = default;
336CLElementwiseMax::~CLElementwiseMax() = default;
337
338void CLElementwiseMax::configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info)
339{
340 configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, act_info);
341}
342
343void CLElementwiseMax::configure(const CLCompileContext &compile_context, ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info)
344{
345 _impl->src_0 = input1;
346 _impl->src_1 = input2;
347 _impl->dst = output;
Georgios Pinitas40f51a62020-11-21 03:04:18 +0000348 _impl->op = std::make_unique<experimental::CLElementwiseMax>();
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100349 _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), act_info);
350}
351
352Status CLElementwiseMax::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info)
353{
354 return experimental::CLElementwiseMax::validate(input1, input2, output, act_info);
355}
356
357void CLElementwiseMax::run()
358{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100359 ITensorPack pack;
360 pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0);
361 pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1);
362 pack.add_tensor(TensorType::ACL_DST, _impl->dst);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100363
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100364 _impl->op->run(pack);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100365}
366
367struct CLElementwiseMin::Impl
368{
369 const ICLTensor *src_0{ nullptr };
370 const ICLTensor *src_1{ nullptr };
371 ICLTensor *dst{ nullptr };
372 std::unique_ptr<experimental::CLElementwiseMin> op{ nullptr };
373};
374
375CLElementwiseMin::CLElementwiseMin()
Georgios Pinitas40f51a62020-11-21 03:04:18 +0000376 : _impl(std::make_unique<Impl>())
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100377{
378}
379CLElementwiseMin::CLElementwiseMin(CLElementwiseMin &&) = default;
380CLElementwiseMin &CLElementwiseMin::operator=(CLElementwiseMin &&) = default;
381CLElementwiseMin::~CLElementwiseMin() = default;
382
383void CLElementwiseMin::configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info)
384{
385 configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, act_info);
386}
387
388void CLElementwiseMin::configure(const CLCompileContext &compile_context, ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info)
389{
390 _impl->src_0 = input1;
391 _impl->src_1 = input2;
392 _impl->dst = output;
Georgios Pinitas40f51a62020-11-21 03:04:18 +0000393 _impl->op = std::make_unique<experimental::CLElementwiseMin>();
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100394 _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), act_info);
395}
396
397Status CLElementwiseMin::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info)
398{
399 return experimental::CLElementwiseMin::validate(input1, input2, output, act_info);
400}
401
402void CLElementwiseMin::run()
403{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100404 ITensorPack pack;
405 pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0);
406 pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1);
407 pack.add_tensor(TensorType::ACL_DST, _impl->dst);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100408
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100409 _impl->op->run(pack);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100410}
411
412struct CLElementwiseSquaredDiff::Impl
413{
414 const ICLTensor *src_0{ nullptr };
415 const ICLTensor *src_1{ nullptr };
416 ICLTensor *dst{ nullptr };
417 std::unique_ptr<experimental::CLElementwiseSquaredDiff> op{ nullptr };
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100418};
419
420CLElementwiseSquaredDiff::CLElementwiseSquaredDiff()
Georgios Pinitas40f51a62020-11-21 03:04:18 +0000421 : _impl(std::make_unique<Impl>())
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100422{
423}
424CLElementwiseSquaredDiff::CLElementwiseSquaredDiff(CLElementwiseSquaredDiff &&) = default;
425CLElementwiseSquaredDiff &CLElementwiseSquaredDiff::operator=(CLElementwiseSquaredDiff &&) = default;
426CLElementwiseSquaredDiff::~CLElementwiseSquaredDiff() = default;
427
428void CLElementwiseSquaredDiff::configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info)
429{
430 configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, act_info);
431}
432
433void CLElementwiseSquaredDiff::configure(const CLCompileContext &compile_context, ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info)
434{
435 _impl->src_0 = input1;
436 _impl->src_1 = input2;
437 _impl->dst = output;
Georgios Pinitas40f51a62020-11-21 03:04:18 +0000438 _impl->op = std::make_unique<experimental::CLElementwiseSquaredDiff>();
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100439 _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), act_info);
440}
441
442Status CLElementwiseSquaredDiff::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info)
443{
444 return experimental::CLElementwiseSquaredDiff::validate(input1, input2, output, act_info);
445}
446
447void CLElementwiseSquaredDiff::run()
448{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100449 ITensorPack pack;
450 pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0);
451 pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1);
452 pack.add_tensor(TensorType::ACL_DST, _impl->dst);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100453
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100454 _impl->op->run(pack);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100455}
456
457struct CLElementwisePower::Impl
458{
459 const ICLTensor *src_0{ nullptr };
460 const ICLTensor *src_1{ nullptr };
461 ICLTensor *dst{ nullptr };
462 std::unique_ptr<experimental::CLElementwisePower> op{ nullptr };
463};
464
465CLElementwisePower::CLElementwisePower()
Georgios Pinitas40f51a62020-11-21 03:04:18 +0000466 : _impl(std::make_unique<Impl>())
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100467{
468}
469CLElementwisePower::CLElementwisePower(CLElementwisePower &&) = default;
470CLElementwisePower &CLElementwisePower::operator=(CLElementwisePower &&) = default;
471CLElementwisePower::~CLElementwisePower() = default;
472
473void CLElementwisePower::configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info)
474{
475 configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, act_info);
476}
477
478void CLElementwisePower::configure(const CLCompileContext &compile_context, ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info)
479{
480 _impl->src_0 = input1;
481 _impl->src_1 = input2;
482 _impl->dst = output;
Georgios Pinitas40f51a62020-11-21 03:04:18 +0000483 _impl->op = std::make_unique<experimental::CLElementwisePower>();
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100484 _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), act_info);
485}
486
487Status CLElementwisePower::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info)
488{
489 return experimental::CLElementwisePower::validate(input1, input2, output, act_info);
490}
491
492void CLElementwisePower::run()
493{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100494 ITensorPack pack;
495 pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0);
496 pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1);
497 pack.add_tensor(TensorType::ACL_DST, _impl->dst);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100498
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100499 _impl->op->run(pack);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100500}
giuros01164a2722018-11-20 18:34:46 +0000501} // namespace arm_compute