blob: 6f664725c5bff5e381ce57e09dbd6a0c2c34618f [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"
27#include "arm_compute/core/CL/kernels/CLElementwiseOperationKernel.h"
Michalis Spyrouad7515d2020-07-24 00:02:23 +010028#include "arm_compute/runtime/CL/CLScheduler.h"
Matthew Bentham92046462020-03-07 22:15:55 +000029#include "support/MemorySupport.h"
giuros01164a2722018-11-20 18:34:46 +000030
31#include <utility>
32
33namespace arm_compute
34{
35namespace
36{
Michalis Spyrouad7515d2020-07-24 00:02:23 +010037void configure_border_handler(const CLCompileContext &compile_context, CLFillBorderKernel &border_handler, BorderSize border_size, ITensorInfo *input1, ITensorInfo *input2, const ITensorInfo *output)
giuros01164a2722018-11-20 18:34:46 +000038{
Michalis Spyrouad7515d2020-07-24 00:02:23 +010039 if(output->dimension(0) > 1)
giuros01164a2722018-11-20 18:34:46 +000040 {
Michalis Spyrouad7515d2020-07-24 00:02:23 +010041 ITensorInfo *broadcasted_info = (input1->dimension(0) == 1) ? input1 : input2;
giuros01164a2722018-11-20 18:34:46 +000042
Michalis Spyrouad7515d2020-07-24 00:02:23 +010043 if(broadcasted_info->dimension(0) == 1)
giuros01164a2722018-11-20 18:34:46 +000044 {
Manuel Bottini2b84be52020-04-08 10:15:51 +010045 border_handler.configure(compile_context, broadcasted_info, border_size, BorderMode::REPLICATE);
giuros01164a2722018-11-20 18:34:46 +000046 }
47 }
48}
Michalis Spyrouad7515d2020-07-24 00:02:23 +010049
Georgios Pinitas0499dff2020-07-31 22:21:38 +010050ITensorPack select_border_input(ITensorPack &tensors)
Michalis Spyrouad7515d2020-07-24 00:02:23 +010051{
Georgios Pinitas0499dff2020-07-31 22:21:38 +010052 ITensorPack pack;
53 if(tensors.get_tensor(TensorType::ACL_DST)->info()->dimension(0) > 1)
Michalis Spyrouad7515d2020-07-24 00:02:23 +010054 {
Georgios Pinitas0499dff2020-07-31 22:21:38 +010055 if(tensors.get_const_tensor(TensorType::ACL_SRC_1)->info()->dimension(0) == 1)
Michalis Spyrouad7515d2020-07-24 00:02:23 +010056 {
Georgios Pinitas0499dff2020-07-31 22:21:38 +010057 pack.add_tensor(TensorType::ACL_SRC, tensors.get_const_tensor(TensorType::ACL_SRC_1));
Michalis Spyrouad7515d2020-07-24 00:02:23 +010058 }
59 else
60 {
Georgios Pinitas0499dff2020-07-31 22:21:38 +010061 pack.add_tensor(TensorType::ACL_SRC, tensors.get_const_tensor(TensorType::ACL_SRC_0));
Michalis Spyrouad7515d2020-07-24 00:02:23 +010062 }
63 }
Georgios Pinitas0499dff2020-07-31 22:21:38 +010064 return pack;
Michalis Spyrouad7515d2020-07-24 00:02:23 +010065}
giuros01164a2722018-11-20 18:34:46 +000066} // namespace
67
Michalis Spyrouad7515d2020-07-24 00:02:23 +010068namespace experimental
giuros01164a2722018-11-20 18:34:46 +000069{
Michalis Spyrouad7515d2020-07-24 00:02:23 +010070CLArithmeticAddition::CLArithmeticAddition()
71 : _border_handler()
72{
Manuel Bottini2b84be52020-04-08 10:15:51 +010073}
74
Michalis Spyrouad7515d2020-07-24 00:02:23 +010075void 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 +010076{
giuros01164a2722018-11-20 18:34:46 +000077 auto k = arm_compute::support::cpp14::make_unique<CLSaturatedArithmeticOperationKernel>();
Manuel Bottini2b84be52020-04-08 10:15:51 +010078 k->configure(compile_context, ArithmeticOperation::ADD, input1, input2, output, policy, act_info);
giuros01164a2722018-11-20 18:34:46 +000079 _kernel = std::move(k);
Manuel Bottini2b84be52020-04-08 10:15:51 +010080 configure_border_handler(compile_context, _border_handler, _kernel->border_size(), input1, input2, output);
giuros01164a2722018-11-20 18:34:46 +000081}
82
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000083Status CLArithmeticAddition::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ConvertPolicy policy, const ActivationLayerInfo &act_info)
giuros01164a2722018-11-20 18:34:46 +000084{
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000085 return CLSaturatedArithmeticOperationKernel::validate(ArithmeticOperation::ADD, input1, input2, output, policy, act_info);
giuros01164a2722018-11-20 18:34:46 +000086}
87
Georgios Pinitas0499dff2020-07-31 22:21:38 +010088void CLArithmeticAddition::run(ITensorPack &tensors)
giuros01164a2722018-11-20 18:34:46 +000089{
Georgios Pinitas0499dff2020-07-31 22:21:38 +010090 auto border_pack = select_border_input(tensors);
91 CLScheduler::get().enqueue_op(_border_handler, border_pack);
92 ICLOperator::run(tensors);
Manuel Bottini2b84be52020-04-08 10:15:51 +010093}
94
Michalis Spyrouad7515d2020-07-24 00:02:23 +010095CLArithmeticSubtraction::CLArithmeticSubtraction()
96 : _border_handler()
97{
98}
99void CLArithmeticSubtraction::configure(const CLCompileContext &compile_context, ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, ConvertPolicy policy,
100 const ActivationLayerInfo &act_info)
Manuel Bottini2b84be52020-04-08 10:15:51 +0100101{
giuros01164a2722018-11-20 18:34:46 +0000102 auto k = arm_compute::support::cpp14::make_unique<CLSaturatedArithmeticOperationKernel>();
Manuel Bottini2b84be52020-04-08 10:15:51 +0100103 k->configure(compile_context, ArithmeticOperation::SUB, input1, input2, output, policy, act_info);
giuros01164a2722018-11-20 18:34:46 +0000104 _kernel = std::move(k);
Manuel Bottini2b84be52020-04-08 10:15:51 +0100105 configure_border_handler(compile_context, _border_handler, _kernel->border_size(), input1, input2, output);
giuros01164a2722018-11-20 18:34:46 +0000106}
107
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000108Status CLArithmeticSubtraction::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ConvertPolicy policy, const ActivationLayerInfo &act_info)
giuros01164a2722018-11-20 18:34:46 +0000109{
110 ARM_COMPUTE_UNUSED(policy);
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000111 return CLSaturatedArithmeticOperationKernel::validate(ArithmeticOperation::SUB, input1, input2, output, policy, act_info);
giuros01164a2722018-11-20 18:34:46 +0000112}
113
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100114void CLArithmeticSubtraction::run(ITensorPack &tensors)
giuros01164a2722018-11-20 18:34:46 +0000115{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100116 auto border_pack = select_border_input(tensors);
117 CLScheduler::get().enqueue_op(_border_handler, border_pack);
118 ICLOperator::run(tensors);
Manuel Bottini2b84be52020-04-08 10:15:51 +0100119}
120
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100121CLArithmeticDivision::CLArithmeticDivision()
122 : _border_handler()
123{
124}
125
126void CLArithmeticDivision::configure(const CLCompileContext &compile_context, ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, const ActivationLayerInfo &act_info)
Manuel Bottini2b84be52020-04-08 10:15:51 +0100127{
giuros01164a2722018-11-20 18:34:46 +0000128 auto k = arm_compute::support::cpp14::make_unique<CLArithmeticOperationKernel>();
Manuel Bottini2b84be52020-04-08 10:15:51 +0100129 k->configure(compile_context, ArithmeticOperation::DIV, input1, input2, output, act_info);
giuros01164a2722018-11-20 18:34:46 +0000130 _kernel = std::move(k);
Manuel Bottini2b84be52020-04-08 10:15:51 +0100131 configure_border_handler(compile_context, _border_handler, _kernel->border_size(), input1, input2, output);
giuros01164a2722018-11-20 18:34:46 +0000132}
133
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000134Status CLArithmeticDivision::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info)
giuros01164a2722018-11-20 18:34:46 +0000135{
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000136 return CLArithmeticOperationKernel::validate(ArithmeticOperation::DIV, input1, input2, output, act_info);
giuros01164a2722018-11-20 18:34:46 +0000137}
138
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100139void CLArithmeticDivision::run(ITensorPack &tensors)
giuros01164a2722018-11-20 18:34:46 +0000140{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100141 auto border_pack = select_border_input(tensors);
142 CLScheduler::get().enqueue_op(_border_handler, border_pack);
143 ICLOperator::run(tensors);
Manuel Bottini2b84be52020-04-08 10:15:51 +0100144}
145
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100146CLElementwiseMax::CLElementwiseMax()
147 : _border_handler()
148{
149}
150
151void CLElementwiseMax::configure(const CLCompileContext &compile_context, ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, const ActivationLayerInfo &act_info)
Manuel Bottini2b84be52020-04-08 10:15:51 +0100152{
giuros01164a2722018-11-20 18:34:46 +0000153 auto k = arm_compute::support::cpp14::make_unique<CLArithmeticOperationKernel>();
Manuel Bottini2b84be52020-04-08 10:15:51 +0100154 k->configure(compile_context, ArithmeticOperation::MAX, input1, input2, output, act_info);
giuros01164a2722018-11-20 18:34:46 +0000155 _kernel = std::move(k);
Manuel Bottini2b84be52020-04-08 10:15:51 +0100156 configure_border_handler(compile_context, _border_handler, _kernel->border_size(), input1, input2, output);
giuros01164a2722018-11-20 18:34:46 +0000157}
158
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000159Status CLElementwiseMax::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info)
giuros01164a2722018-11-20 18:34:46 +0000160{
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000161 return CLArithmeticOperationKernel::validate(ArithmeticOperation::MAX, input1, input2, output, act_info);
giuros01164a2722018-11-20 18:34:46 +0000162}
163
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100164void CLElementwiseMax::run(ITensorPack &tensors)
giuros01164a2722018-11-20 18:34:46 +0000165{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100166 auto border_pack = select_border_input(tensors);
167 CLScheduler::get().enqueue_op(_border_handler, border_pack);
168 ICLOperator::run(tensors);
Manuel Bottini2b84be52020-04-08 10:15:51 +0100169}
170
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100171CLElementwiseMin::CLElementwiseMin()
172 : _border_handler()
173{
174}
175
176void CLElementwiseMin::configure(const CLCompileContext &compile_context, ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, const ActivationLayerInfo &act_info)
Manuel Bottini2b84be52020-04-08 10:15:51 +0100177{
giuros01164a2722018-11-20 18:34:46 +0000178 auto k = arm_compute::support::cpp14::make_unique<CLArithmeticOperationKernel>();
Manuel Bottini2b84be52020-04-08 10:15:51 +0100179 k->configure(compile_context, ArithmeticOperation::MIN, input1, input2, output, act_info);
giuros01164a2722018-11-20 18:34:46 +0000180 _kernel = std::move(k);
Manuel Bottini2b84be52020-04-08 10:15:51 +0100181 configure_border_handler(compile_context, _border_handler, _kernel->border_size(), input1, input2, output);
giuros01164a2722018-11-20 18:34:46 +0000182}
183
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000184Status CLElementwiseMin::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info)
giuros01164a2722018-11-20 18:34:46 +0000185{
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000186 return CLArithmeticOperationKernel::validate(ArithmeticOperation::MIN, input1, input2, output, act_info);
giuros01164a2722018-11-20 18:34:46 +0000187}
188
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100189void CLElementwiseMin::run(ITensorPack &tensors)
giuros01164a2722018-11-20 18:34:46 +0000190{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100191 auto border_pack = select_border_input(tensors);
192 CLScheduler::get().enqueue_op(_border_handler, border_pack);
193 ICLOperator::run(tensors);
Manuel Bottini2b84be52020-04-08 10:15:51 +0100194}
195
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100196CLElementwiseSquaredDiff::CLElementwiseSquaredDiff()
197 : _border_handler()
198{
199}
200
201void CLElementwiseSquaredDiff::configure(const CLCompileContext &compile_context, ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, const ActivationLayerInfo &act_info)
Manuel Bottini2b84be52020-04-08 10:15:51 +0100202{
giuros01164a2722018-11-20 18:34:46 +0000203 auto k = arm_compute::support::cpp14::make_unique<CLArithmeticOperationKernel>();
Manuel Bottini2b84be52020-04-08 10:15:51 +0100204 k->configure(compile_context, ArithmeticOperation::SQUARED_DIFF, input1, input2, output, act_info);
giuros01164a2722018-11-20 18:34:46 +0000205 _kernel = std::move(k);
Manuel Bottini2b84be52020-04-08 10:15:51 +0100206 configure_border_handler(compile_context, _border_handler, _kernel->border_size(), input1, input2, output);
giuros01164a2722018-11-20 18:34:46 +0000207}
208
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000209Status CLElementwiseSquaredDiff::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info)
giuros01164a2722018-11-20 18:34:46 +0000210{
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000211 return CLArithmeticOperationKernel::validate(ArithmeticOperation::SQUARED_DIFF, input1, input2, output, act_info);
giuros01164a2722018-11-20 18:34:46 +0000212}
Usama Arif52c54f62019-05-14 10:22:36 +0100213
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100214void CLElementwiseSquaredDiff::run(ITensorPack &tensors)
Usama Arif52c54f62019-05-14 10:22:36 +0100215{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100216 auto border_pack = select_border_input(tensors);
217 CLScheduler::get().enqueue_op(_border_handler, border_pack);
218 ICLOperator::run(tensors);
Manuel Bottini2b84be52020-04-08 10:15:51 +0100219}
220
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100221CLElementwisePower::CLElementwisePower()
222 : _border_handler()
223{
224}
225
226void CLElementwisePower::configure(const CLCompileContext &compile_context, ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, const ActivationLayerInfo &act_info)
Manuel Bottini2b84be52020-04-08 10:15:51 +0100227{
Usama Arif52c54f62019-05-14 10:22:36 +0100228 auto k = arm_compute::support::cpp14::make_unique<CLArithmeticOperationKernel>();
Manuel Bottini2b84be52020-04-08 10:15:51 +0100229 k->configure(compile_context, ArithmeticOperation::POWER, input1, input2, output, act_info);
Usama Arif52c54f62019-05-14 10:22:36 +0100230 _kernel = std::move(k);
Manuel Bottini2b84be52020-04-08 10:15:51 +0100231 configure_border_handler(compile_context, _border_handler, _kernel->border_size(), input1, input2, output);
Usama Arif52c54f62019-05-14 10:22:36 +0100232}
233
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000234Status CLElementwisePower::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info)
Usama Arif52c54f62019-05-14 10:22:36 +0100235{
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000236 return CLArithmeticOperationKernel::validate(ArithmeticOperation::POWER, input1, input2, output, act_info);
Usama Arif52c54f62019-05-14 10:22:36 +0100237}
238
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100239void CLElementwisePower::run(ITensorPack &tensors)
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100240{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100241 auto border_pack = select_border_input(tensors);
242 CLScheduler::get().enqueue_op(_border_handler, border_pack);
243 ICLOperator::run(tensors);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100244}
245} // namespace experimental
246
247struct CLArithmeticAddition::Impl
248{
249 const ICLTensor *src_0{ nullptr };
250 const ICLTensor *src_1{ nullptr };
251 ICLTensor *dst{ nullptr };
252 std::unique_ptr<experimental::CLArithmeticAddition> op{ nullptr };
253};
254
255CLArithmeticAddition::CLArithmeticAddition()
256 : _impl(support::cpp14::make_unique<Impl>())
257{
258}
259CLArithmeticAddition::CLArithmeticAddition(CLArithmeticAddition &&) = default;
260CLArithmeticAddition &CLArithmeticAddition::operator=(CLArithmeticAddition &&) = default;
261CLArithmeticAddition::~CLArithmeticAddition() = default;
262
263void CLArithmeticAddition::configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, ConvertPolicy policy, const ActivationLayerInfo &act_info)
264{
265 configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, policy, act_info);
266}
267
268void CLArithmeticAddition::configure(const CLCompileContext &compile_context, const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output, ConvertPolicy policy,
269 const ActivationLayerInfo &act_info)
270{
271 _impl->src_0 = input1;
272 _impl->src_1 = input2;
273 _impl->dst = output;
274 _impl->op = arm_compute::support::cpp14::make_unique<experimental::CLArithmeticAddition>();
275 _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), policy, act_info);
276}
277
278Status CLArithmeticAddition::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ConvertPolicy policy, const ActivationLayerInfo &act_info)
279{
280 return experimental::CLArithmeticAddition::validate(input1, input2, output, policy, act_info);
281}
282
283void CLArithmeticAddition::run()
284{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100285 ITensorPack pack;
286 pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0);
287 pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1);
288 pack.add_tensor(TensorType::ACL_DST, _impl->dst);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100289
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100290 _impl->op->run(pack);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100291}
292
293struct CLArithmeticSubtraction::Impl
294{
295 const ICLTensor *src_0{ nullptr };
296 const ICLTensor *src_1{ nullptr };
297 ICLTensor *dst{ nullptr };
298 std::unique_ptr<experimental::CLArithmeticSubtraction> op{ nullptr };
299};
300
301CLArithmeticSubtraction::CLArithmeticSubtraction()
302 : _impl(support::cpp14::make_unique<Impl>())
303{
304}
305CLArithmeticSubtraction::CLArithmeticSubtraction(CLArithmeticSubtraction &&) = default;
306CLArithmeticSubtraction &CLArithmeticSubtraction::operator=(CLArithmeticSubtraction &&) = default;
307CLArithmeticSubtraction::~CLArithmeticSubtraction() = default;
308
309void CLArithmeticSubtraction::configure(const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output, ConvertPolicy policy, const ActivationLayerInfo &act_info)
310{
311 configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, policy, act_info);
312}
313
314void CLArithmeticSubtraction::configure(const CLCompileContext &compile_context, const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output, ConvertPolicy policy,
315 const ActivationLayerInfo &act_info)
316{
317 _impl->src_0 = input1;
318 _impl->src_1 = input2;
319 _impl->dst = output;
320 _impl->op = arm_compute::support::cpp14::make_unique<experimental::CLArithmeticSubtraction>();
321 _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), policy, act_info);
322}
323
324Status CLArithmeticSubtraction::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ConvertPolicy policy, const ActivationLayerInfo &act_info)
325{
326 return experimental::CLArithmeticSubtraction::validate(input1, input2, output, policy, act_info);
327}
328
329void CLArithmeticSubtraction::run()
330{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100331 ITensorPack pack;
332 pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0);
333 pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1);
334 pack.add_tensor(TensorType::ACL_DST, _impl->dst);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100335
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100336 _impl->op->run(pack);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100337}
338
339struct CLArithmeticDivision::Impl
340{
341 const ICLTensor *src_0{ nullptr };
342 const ICLTensor *src_1{ nullptr };
343 ICLTensor *dst{ nullptr };
344 std::unique_ptr<experimental::CLArithmeticDivision> op{ nullptr };
345};
346
347CLArithmeticDivision::CLArithmeticDivision()
348 : _impl(support::cpp14::make_unique<Impl>())
349{
350}
351CLArithmeticDivision::CLArithmeticDivision(CLArithmeticDivision &&) = default;
352CLArithmeticDivision &CLArithmeticDivision::operator=(CLArithmeticDivision &&) = default;
353CLArithmeticDivision::~CLArithmeticDivision() = default;
354
355void CLArithmeticDivision::configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info)
356{
357 configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, act_info);
358}
359
360void CLArithmeticDivision::configure(const CLCompileContext &compile_context, const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info)
361{
362 _impl->src_0 = input1;
363 _impl->src_1 = input2;
364 _impl->dst = output;
365 _impl->op = arm_compute::support::cpp14::make_unique<experimental::CLArithmeticDivision>();
366 _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), act_info);
367}
368
369Status CLArithmeticDivision::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info)
370{
371 return experimental::CLArithmeticDivision::validate(input1, input2, output, act_info);
372}
373
374void CLArithmeticDivision::run()
375{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100376 ITensorPack pack;
377 pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0);
378 pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1);
379 pack.add_tensor(TensorType::ACL_DST, _impl->dst);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100380
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100381 _impl->op->run(pack);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100382}
383
384struct CLElementwiseMax::Impl
385{
386 const ICLTensor *src_0{ nullptr };
387 const ICLTensor *src_1{ nullptr };
388 ICLTensor *dst{ nullptr };
389 std::unique_ptr<experimental::CLElementwiseMax> op{ nullptr };
390};
391
392CLElementwiseMax::CLElementwiseMax()
393 : _impl(support::cpp14::make_unique<Impl>())
394{
395}
396CLElementwiseMax::CLElementwiseMax(CLElementwiseMax &&) = default;
397CLElementwiseMax &CLElementwiseMax::operator=(CLElementwiseMax &&) = default;
398CLElementwiseMax::~CLElementwiseMax() = default;
399
400void CLElementwiseMax::configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info)
401{
402 configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, act_info);
403}
404
405void CLElementwiseMax::configure(const CLCompileContext &compile_context, ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info)
406{
407 _impl->src_0 = input1;
408 _impl->src_1 = input2;
409 _impl->dst = output;
410 _impl->op = arm_compute::support::cpp14::make_unique<experimental::CLElementwiseMax>();
411 _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), act_info);
412}
413
414Status CLElementwiseMax::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info)
415{
416 return experimental::CLElementwiseMax::validate(input1, input2, output, act_info);
417}
418
419void CLElementwiseMax::run()
420{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100421 ITensorPack pack;
422 pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0);
423 pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1);
424 pack.add_tensor(TensorType::ACL_DST, _impl->dst);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100425
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100426 _impl->op->run(pack);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100427}
428
429struct CLElementwiseMin::Impl
430{
431 const ICLTensor *src_0{ nullptr };
432 const ICLTensor *src_1{ nullptr };
433 ICLTensor *dst{ nullptr };
434 std::unique_ptr<experimental::CLElementwiseMin> op{ nullptr };
435};
436
437CLElementwiseMin::CLElementwiseMin()
438 : _impl(support::cpp14::make_unique<Impl>())
439{
440}
441CLElementwiseMin::CLElementwiseMin(CLElementwiseMin &&) = default;
442CLElementwiseMin &CLElementwiseMin::operator=(CLElementwiseMin &&) = default;
443CLElementwiseMin::~CLElementwiseMin() = default;
444
445void CLElementwiseMin::configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info)
446{
447 configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, act_info);
448}
449
450void CLElementwiseMin::configure(const CLCompileContext &compile_context, ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info)
451{
452 _impl->src_0 = input1;
453 _impl->src_1 = input2;
454 _impl->dst = output;
455 _impl->op = arm_compute::support::cpp14::make_unique<experimental::CLElementwiseMin>();
456 _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), act_info);
457}
458
459Status CLElementwiseMin::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info)
460{
461 return experimental::CLElementwiseMin::validate(input1, input2, output, act_info);
462}
463
464void CLElementwiseMin::run()
465{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100466 ITensorPack pack;
467 pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0);
468 pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1);
469 pack.add_tensor(TensorType::ACL_DST, _impl->dst);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100470
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100471 _impl->op->run(pack);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100472}
473
474struct CLElementwiseSquaredDiff::Impl
475{
476 const ICLTensor *src_0{ nullptr };
477 const ICLTensor *src_1{ nullptr };
478 ICLTensor *dst{ nullptr };
479 std::unique_ptr<experimental::CLElementwiseSquaredDiff> op{ nullptr };
480 std::unique_ptr<CLFillBorderKernel> _border_handler{ nullptr };
481};
482
483CLElementwiseSquaredDiff::CLElementwiseSquaredDiff()
484 : _impl(support::cpp14::make_unique<Impl>())
485{
486}
487CLElementwiseSquaredDiff::CLElementwiseSquaredDiff(CLElementwiseSquaredDiff &&) = default;
488CLElementwiseSquaredDiff &CLElementwiseSquaredDiff::operator=(CLElementwiseSquaredDiff &&) = default;
489CLElementwiseSquaredDiff::~CLElementwiseSquaredDiff() = default;
490
491void CLElementwiseSquaredDiff::configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info)
492{
493 configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, act_info);
494}
495
496void CLElementwiseSquaredDiff::configure(const CLCompileContext &compile_context, ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info)
497{
498 _impl->src_0 = input1;
499 _impl->src_1 = input2;
500 _impl->dst = output;
501 _impl->op = arm_compute::support::cpp14::make_unique<experimental::CLElementwiseSquaredDiff>();
502 _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), act_info);
503}
504
505Status CLElementwiseSquaredDiff::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info)
506{
507 return experimental::CLElementwiseSquaredDiff::validate(input1, input2, output, act_info);
508}
509
510void CLElementwiseSquaredDiff::run()
511{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100512 ITensorPack pack;
513 pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0);
514 pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1);
515 pack.add_tensor(TensorType::ACL_DST, _impl->dst);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100516
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100517 _impl->op->run(pack);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100518}
519
520struct CLElementwisePower::Impl
521{
522 const ICLTensor *src_0{ nullptr };
523 const ICLTensor *src_1{ nullptr };
524 ICLTensor *dst{ nullptr };
525 std::unique_ptr<experimental::CLElementwisePower> op{ nullptr };
526};
527
528CLElementwisePower::CLElementwisePower()
529 : _impl(support::cpp14::make_unique<Impl>())
530{
531}
532CLElementwisePower::CLElementwisePower(CLElementwisePower &&) = default;
533CLElementwisePower &CLElementwisePower::operator=(CLElementwisePower &&) = default;
534CLElementwisePower::~CLElementwisePower() = default;
535
536void CLElementwisePower::configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info)
537{
538 configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, act_info);
539}
540
541void CLElementwisePower::configure(const CLCompileContext &compile_context, ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info)
542{
543 _impl->src_0 = input1;
544 _impl->src_1 = input2;
545 _impl->dst = output;
546 _impl->op = arm_compute::support::cpp14::make_unique<experimental::CLElementwisePower>();
547 _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), act_info);
548}
549
550Status CLElementwisePower::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info)
551{
552 return experimental::CLElementwisePower::validate(input1, input2, output, act_info);
553}
554
555void CLElementwisePower::run()
556{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100557 ITensorPack pack;
558 pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0);
559 pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1);
560 pack.add_tensor(TensorType::ACL_DST, _impl->dst);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100561
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100562 _impl->op->run(pack);
Michalis Spyrouad7515d2020-07-24 00:02:23 +0100563}
giuros01164a2722018-11-20 18:34:46 +0000564} // namespace arm_compute