Compute Library
 21.02
NEPixelWiseMultiplication.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-2020 Arm Limited.
3  *
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  */
25 
28 
29 #include <utility>
30 
31 namespace arm_compute
32 {
33 namespace experimental
34 {
35 void NEPixelWiseMultiplication::configure(ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, float scale, ConvertPolicy overflow_policy, RoundingPolicy rounding_policy,
36  const ActivationLayerInfo &act_info)
37 {
38  ARM_COMPUTE_UNUSED(act_info);
39  auto k = std::make_unique<NEPixelWiseMultiplicationKernel>();
40  k->configure(input1, input2, output, scale, overflow_policy, rounding_policy);
41  _kernel = std::move(k);
42 }
43 Status NEPixelWiseMultiplication::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, float scale, ConvertPolicy overflow_policy, RoundingPolicy rounding_policy,
44  const ActivationLayerInfo &act_info)
45 {
47  return NEPixelWiseMultiplicationKernel::validate(input1, input2, output, scale, overflow_policy, rounding_policy);
48 }
49 
51 {
52  ARM_COMPUTE_UNUSED(act_info);
53  auto k = std::make_unique<NEComplexPixelWiseMultiplicationKernel>();
54  k->configure(input1, input2, output);
55  _kernel = std::move(k);
56 }
57 
58 Status NEComplexPixelWiseMultiplication::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info)
59 {
61  return NEComplexPixelWiseMultiplicationKernel::validate(input1, input2, output);
62 }
63 } // namespace experimental
64 
65 struct NEPixelWiseMultiplication::Impl
66 {
67  const ITensor *src_0{ nullptr };
68  const ITensor *src_1{ nullptr };
69  ITensor *dst{ nullptr };
70  std::unique_ptr<experimental::NEPixelWiseMultiplication> op{ nullptr };
71 };
72 
74  : _impl(std::make_unique<Impl>())
75 {
76 }
80 
81 Status NEPixelWiseMultiplication::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, float scale, ConvertPolicy overflow_policy, RoundingPolicy rounding_policy,
82  const ActivationLayerInfo &act_info)
83 {
84  return experimental::NEPixelWiseMultiplication::validate(input1, input2, output, scale, overflow_policy, rounding_policy, act_info);
85 }
86 
87 void NEPixelWiseMultiplication::configure(const ITensor *input1, const ITensor *input2, ITensor *output, float scale, ConvertPolicy overflow_policy, RoundingPolicy rounding_policy,
88  const ActivationLayerInfo &act_info)
89 {
90  _impl->src_0 = input1;
91  _impl->src_1 = input2;
92  _impl->dst = output;
93  _impl->op = std::make_unique<experimental::NEPixelWiseMultiplication>();
94  _impl->op->configure(input1->info(), input2->info(), output->info(), scale, overflow_policy, rounding_policy, act_info);
95 }
96 
98 {
99  ITensorPack pack;
100  pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0);
101  pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1);
102  pack.add_tensor(TensorType::ACL_DST, _impl->dst);
103  _impl->op->run(pack);
104 }
105 
106 struct NEComplexPixelWiseMultiplication::Impl
107 {
108  ITensor *src_0{ nullptr };
109  ITensor *src_1{ nullptr };
110  ITensor *dst{ nullptr };
111  std::unique_ptr<experimental::NEComplexPixelWiseMultiplication> op{ nullptr };
112 };
113 
115  : _impl(std::make_unique<Impl>())
116 {
117 }
121 
123 {
124  return experimental::NEComplexPixelWiseMultiplication::validate(input1, input2, output, act_info);
125 }
126 
128 {
129  _impl->src_0 = input1;
130  _impl->src_1 = input2;
131  _impl->dst = output;
132  _impl->op = std::make_unique<experimental::NEComplexPixelWiseMultiplication>();
133  _impl->op->configure(input1->info(), input2->info(), output->info(), act_info);
134 }
135 
137 {
138  ITensorPack pack;
139  pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0);
140  pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1);
141  pack.add_tensor(TensorType::ACL_DST, _impl->dst);
142  _impl->op->run(pack);
143 }
144 } // namespace arm_compute
~NEComplexPixelWiseMultiplication()
Default Destructor.
NEPixelWiseMultiplication & operator=(const NEPixelWiseMultiplication &)=delete
Prevent instances of this class from being copied (As this class contains pointers) ...
void run() override
Run the kernels contained in the function.
void run() override
Run the kernels contained in the function.
bool enabled() const
Check if initialised.
Definition: Types.h:1600
static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, float scale, ConvertPolicy overflow_policy, RoundingPolicy rounding_policy, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Static function to check if given info will lead to a valid configuration of NEPixelWiseMultiplicatio...
Basic function to run NEComplexPixelWiseMultiplicationKernel.
Store the tensor&#39;s metadata.
Definition: ITensorInfo.h:40
Status class.
Definition: Error.h:52
static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Static function to check if given info will lead to a valid configuration of NEComplexPixelWiseMultip...
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
Definition: Error.h:296
Activation Layer Information class.
Definition: Types.h:1550
static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output)
Static function to check if given info will lead to a valid configuration of NEComplexPixelWiseMultip...
Interface for Neon tensor.
Definition: ITensor.h:36
Copyright (c) 2017-2021 Arm Limited.
void configure(ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Initialise the kernel&#39;s inputs, output.
void configure(ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, float scale, ConvertPolicy overflow_policy, RoundingPolicy rounding_policy, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Initialise the kernel&#39;s inputs, output and convertion policy.
static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, float scale, ConvertPolicy overflow_policy, RoundingPolicy rounding_policy)
Static function to check if given info will lead to a valid configuration of NEPixelWiseMultiplicatio...
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152
void configure(const ITensor *input1, const ITensor *input2, ITensor *output, float scale, ConvertPolicy overflow_policy, RoundingPolicy rounding_policy, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Initialise the kernel&#39;s inputs, output and convertion policy.
RoundingPolicy
Rounding method.
Definition: Rounding.h:30
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor&#39;s metadata.
~NEPixelWiseMultiplication()
Default Destructor.
static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, float scale, ConvertPolicy overflow_policy, RoundingPolicy rounding_policy, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Static function to check if given info will lead to a valid configuration of NEPixelWiseMultiplicatio...
Basic function to run NEPixelWiseMultiplicationKernel.
static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Static function to check if given info will lead to a valid configuration of NEComplexPixelWiseMultip...
Tensor packing service.
Definition: ITensorPack.h:37
NEComplexPixelWiseMultiplication & operator=(const NEComplexPixelWiseMultiplication &)=delete
Prevent instances of this class from being copied (As this class contains pointers) ...
void configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Initialise the kernel&#39;s inputs, output.
ConvertPolicy
Policy to handle overflow.
Definition: Types.h:385
void add_tensor(int id, ITensor *tensor)
Add tensor to the pack.
Definition: ITensorPack.cpp:30