blob: 97155a9e74fab7d1bafd5ecb608748fada420fba [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Sheri Zhang1e3ab422021-03-16 17:35:08 +00002 * Copyright (c) 2016-2021 Arm Limited.
Anthony Barbier6ff3b192017-09-04 18:44:23 +01003 *
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 */
24#include "arm_compute/runtime/NEON/functions/NEPixelWiseMultiplication.h"
25
Michalis Spyrou861f0db2018-02-26 16:47:58 +000026#include "arm_compute/core/ITensor.h"
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010027
Georgios Pinitas7891a732021-08-20 21:39:25 +010028#include "src/cpu/operators/CpuMul.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010029
30#include <utility>
31
giuros01154bc1c2019-03-26 17:44:40 +000032namespace arm_compute
33{
Michalis Spyrou6eb73452020-07-02 17:39:25 +010034struct NEPixelWiseMultiplication::Impl
35{
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010036 const ITensor *src_0{nullptr};
37 const ITensor *src_1{nullptr};
38 ITensor *dst{nullptr};
39 std::unique_ptr<cpu::CpuMul> op{nullptr};
Michalis Spyrou6eb73452020-07-02 17:39:25 +010040};
41
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010042NEPixelWiseMultiplication::NEPixelWiseMultiplication() : _impl(std::make_unique<Impl>())
Michalis Spyrou6eb73452020-07-02 17:39:25 +010043{
44}
Sheri Zhang1e3ab422021-03-16 17:35:08 +000045NEPixelWiseMultiplication::~NEPixelWiseMultiplication() = default;
Michalis Spyrou6eb73452020-07-02 17:39:25 +010046
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010047Status NEPixelWiseMultiplication::validate(const ITensorInfo *input1,
48 const ITensorInfo *input2,
49 const ITensorInfo *output,
50 float scale,
51 ConvertPolicy overflow_policy,
52 RoundingPolicy rounding_policy,
Michalis Spyrou6eb73452020-07-02 17:39:25 +010053 const ActivationLayerInfo &act_info)
54{
Georgios Pinitas0dc0d8e2021-04-30 03:18:37 +010055 return cpu::CpuMul::validate(input1, input2, output, scale, overflow_policy, rounding_policy, act_info);
Michalis Spyrou6eb73452020-07-02 17:39:25 +010056}
57
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010058void NEPixelWiseMultiplication::configure(const ITensor *input1,
59 const ITensor *input2,
60 ITensor *output,
61 float scale,
62 ConvertPolicy overflow_policy,
63 RoundingPolicy rounding_policy,
Michalis Spyrou6eb73452020-07-02 17:39:25 +010064 const ActivationLayerInfo &act_info)
65{
66 _impl->src_0 = input1;
67 _impl->src_1 = input2;
68 _impl->dst = output;
Georgios Pinitas0dc0d8e2021-04-30 03:18:37 +010069 _impl->op = std::make_unique<cpu::CpuMul>();
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010070 _impl->op->configure(input1->info(), input2->info(), output->info(), scale, overflow_policy, rounding_policy,
71 act_info);
Michalis Spyrou6eb73452020-07-02 17:39:25 +010072}
73
74void NEPixelWiseMultiplication::run()
75{
Georgios Pinitas0499dff2020-07-31 22:21:38 +010076 ITensorPack pack;
77 pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0);
78 pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1);
79 pack.add_tensor(TensorType::ACL_DST, _impl->dst);
80 _impl->op->run(pack);
Michalis Spyrou6eb73452020-07-02 17:39:25 +010081}
82
83struct NEComplexPixelWiseMultiplication::Impl
84{
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010085 ITensor *src_0{nullptr};
86 ITensor *src_1{nullptr};
87 ITensor *dst{nullptr};
88 std::unique_ptr<cpu::CpuComplexMul> op{nullptr};
Michalis Spyrou6eb73452020-07-02 17:39:25 +010089};
90
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010091NEComplexPixelWiseMultiplication::NEComplexPixelWiseMultiplication() : _impl(std::make_unique<Impl>())
Michalis Spyrou6eb73452020-07-02 17:39:25 +010092{
93}
Sheri Zhang1e3ab422021-03-16 17:35:08 +000094NEComplexPixelWiseMultiplication::~NEComplexPixelWiseMultiplication() = default;
Michalis Spyrou6eb73452020-07-02 17:39:25 +010095
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010096Status NEComplexPixelWiseMultiplication::validate(const ITensorInfo *input1,
97 const ITensorInfo *input2,
98 const ITensorInfo *output,
99 const ActivationLayerInfo &act_info)
Michalis Spyrou6eb73452020-07-02 17:39:25 +0100100{
Georgios Pinitas0dc0d8e2021-04-30 03:18:37 +0100101 return cpu::CpuComplexMul::validate(input1, input2, output, act_info);
Michalis Spyrou6eb73452020-07-02 17:39:25 +0100102}
103
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100104void NEComplexPixelWiseMultiplication::configure(ITensor *input1,
105 ITensor *input2,
106 ITensor *output,
107 const ActivationLayerInfo &act_info)
Michalis Spyrou6eb73452020-07-02 17:39:25 +0100108{
109 _impl->src_0 = input1;
110 _impl->src_1 = input2;
111 _impl->dst = output;
Georgios Pinitas0dc0d8e2021-04-30 03:18:37 +0100112 _impl->op = std::make_unique<cpu::CpuComplexMul>();
Michalis Spyrou6eb73452020-07-02 17:39:25 +0100113 _impl->op->configure(input1->info(), input2->info(), output->info(), act_info);
114}
115
116void NEComplexPixelWiseMultiplication::run()
117{
Georgios Pinitas0499dff2020-07-31 22:21:38 +0100118 ITensorPack pack;
119 pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0);
120 pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1);
121 pack.add_tensor(TensorType::ACL_DST, _impl->dst);
122 _impl->op->run(pack);
Michalis Spyrou6eb73452020-07-02 17:39:25 +0100123}
giuros01154bc1c2019-03-26 17:44:40 +0000124} // namespace arm_compute