blob: 29677b74621fdcd7a797139c491ba12116c49921 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01002 * Copyright (c) 2016-2020 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 */
Michalis Spyrouf4643372019-11-29 16:17:13 +000024#ifndef ARM_COMPUTE_NEPIXELWISEMULTIPLICATION_H
25#define ARM_COMPUTE_NEPIXELWISEMULTIPLICATION_H
Anthony Barbier6ff3b192017-09-04 18:44:23 +010026
27#include "arm_compute/core/Types.h"
Michalis Spyrou6eb73452020-07-02 17:39:25 +010028#include "arm_compute/runtime/IFunction.h"
29#include "arm_compute/runtime/NEON/INEOperator.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010030
31namespace arm_compute
32{
33class ITensor;
34
Michalis Spyrou6eb73452020-07-02 17:39:25 +010035namespace experimental
36{
Anthony Barbier6ff3b192017-09-04 18:44:23 +010037/** Basic function to run @ref NEPixelWiseMultiplicationKernel */
Michalis Spyrou6eb73452020-07-02 17:39:25 +010038class NEPixelWiseMultiplication : public INEOperator
Anthony Barbier6ff3b192017-09-04 18:44:23 +010039{
40public:
41 /** Initialise the kernel's inputs, output and convertion policy.
42 *
Michele Di Giorgiof9b595a2020-07-03 13:34:52 +010043 * Valid configurations (Input1,Input2) -> Output :
44 *
45 * - (U8,U8) -> U8
46 * - (U8,U8) -> S16
47 * - (U8,S16) -> S16
48 * - (S16,U8) -> S16
49 * - (S16,S16) -> S16
50 * - (F16,F16) -> F16
51 * - (F32,F32) -> F32
52 * - (QASYMM8,QASYMM8) -> QASYMM8
53 * - (QASYMM8_SIGNED,QASYMM8_SIGNED) -> QASYMM8_SIGNED
54 * - (QSYMM16,QSYMM16) -> QSYMM16
55 * - (QSYMM16,QSYMM16) -> S32
56 *
Manuel Bottini79fa9a22019-02-22 17:54:22 +000057 * @note For @p scale equal to 1/255 only round to nearest even (implemented as round half up) is supported.
58 * For all other scale values only round to zero (implemented as round towards minus infinity) is supported.
59 *
Michele Di Giorgiof9b595a2020-07-03 13:34:52 +010060 * @param[in, out] input1 First input tensor. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/F32
Manuel Bottini79fa9a22019-02-22 17:54:22 +000061 * This input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
Michele Di Giorgiof9b595a2020-07-03 13:34:52 +010062 * @param[in, out] input2 Second input tensor. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/F32
Manuel Bottini79fa9a22019-02-22 17:54:22 +000063 * This input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
Michele Di Giorgiof9b595a2020-07-03 13:34:52 +010064 * @param[out] output Output tensor. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/F32/S32
Michalis Spyrou861f0db2018-02-26 16:47:58 +000065 * @param[in] scale Scale to apply after multiplication.
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +010066 * Scale must be positive and its value must be either 1/255 or 1/2^n where n is between 0 and 15.
Pablo Tello52ea9c22019-12-10 11:28:53 +000067 * @param[in] overflow_policy Overflow policy. ConvertPolicy cannot be WRAP if datatype is QASYMM8, QASYMM8_SIGNED or QSYMM16.
Michalis Spyrou861f0db2018-02-26 16:47:58 +000068 * @param[in] rounding_policy Rounding policy.
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000069 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
Anthony Barbier6ff3b192017-09-04 18:44:23 +010070 */
Michalis Spyrou6eb73452020-07-02 17:39:25 +010071 void configure(ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, float scale, ConvertPolicy overflow_policy, RoundingPolicy rounding_policy,
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000072 const ActivationLayerInfo &act_info = ActivationLayerInfo());
Ioan-Cristian Szabo754e9522017-11-28 18:29:43 +000073 /** Static function to check if given info will lead to a valid configuration of @ref NEPixelWiseMultiplication
74 *
Michele Di Giorgiof9b595a2020-07-03 13:34:52 +010075 * Valid configurations (Input1,Input2) -> Output :
76 *
77 * - (U8,U8) -> U8
78 * - (U8,U8) -> S16
79 * - (U8,S16) -> S16
80 * - (S16,U8) -> S16
81 * - (S16,S16) -> S16
82 * - (F16,F16) -> F16
83 * - (F32,F32) -> F32
84 * - (QASYMM8,QASYMM8) -> QASYMM8
85 * - (QASYMM8_SIGNED,QASYMM8_SIGNED) -> QASYMM8_SIGNED
86 * - (QSYMM16,QSYMM16) -> QSYMM16
87 * - (QSYMM16,QSYMM16) -> S32
88 *
Manuel Bottini79fa9a22019-02-22 17:54:22 +000089 * @note For @p scale equal to 1/255 only round to nearest even (implemented as round half up) is supported.
90 * For all other scale values only round to zero (implemented as round towards minus infinity) is supported.
91 *
Michele Di Giorgiof9b595a2020-07-03 13:34:52 +010092 * @param[in] input1 First input tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/F32
93 * @param[in] input2 Second input tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/F32
94 * @param[in] output Output tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/F32/S32
Manuel Bottini79fa9a22019-02-22 17:54:22 +000095 * @param[in] scale Scale to apply after multiplication.
96 * Scale must be positive and its value must be either 1/255 or 1/2^n where n is between 0 and 15.
Pablo Tello52ea9c22019-12-10 11:28:53 +000097 * @param[in] overflow_policy Overflow policy. ConvertPolicy cannot be WRAP if datatype is QASYMM8, QASYMM8_SIGNED or QSYMM16.
Ioan-Cristian Szabo754e9522017-11-28 18:29:43 +000098 * @param[in] rounding_policy Rounding policy.
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000099 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
Ioan-Cristian Szabo754e9522017-11-28 18:29:43 +0000100 *
Georgios Pinitas631c41a2017-12-06 11:53:03 +0000101 * @return a status
Ioan-Cristian Szabo754e9522017-11-28 18:29:43 +0000102 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000103 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, float scale, ConvertPolicy overflow_policy, RoundingPolicy rounding_policy,
104 const ActivationLayerInfo &act_info = ActivationLayerInfo());
Michalis Spyrou6eb73452020-07-02 17:39:25 +0100105
106 // Inherited methods overridden:
107 MemoryRequirements workspace() const override;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100108};
giuros01154bc1c2019-03-26 17:44:40 +0000109
110/** Basic function to run @ref NEComplexPixelWiseMultiplicationKernel. */
Michalis Spyrou6eb73452020-07-02 17:39:25 +0100111class NEComplexPixelWiseMultiplication : public INEOperator
giuros01154bc1c2019-03-26 17:44:40 +0000112{
113public:
114 /** Initialise the kernel's inputs, output.
115 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000116 * @param[in, out] input1 An input tensor. Data types supported: F32. Number of channels supported: 2 (complex tensor).
117 * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
118 * @param[in, out] input2 An input tensor. Data types supported: same as @p input1. Number of channels supported: same as @p input1.
119 * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
120 * @param[out] output The output tensor. Data types supported: same as @p input1. Number of channels: same as @p input1.
121 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
giuros01154bc1c2019-03-26 17:44:40 +0000122 */
Michalis Spyrou6eb73452020-07-02 17:39:25 +0100123 void configure(ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
124 /** Static function to check if given info will lead to a valid configuration of @ref NEComplexPixelWiseMultiplication
125 *
126 * @param[in] input1 An input tensor info. Data types supported: F32. Number of channels supported: 2 (complex tensor).
127 * @param[in] input2 An input tensor info. Data types supported: same as @p input1. Number of channels supported: same as @p input1.
128 * @param[in] output The output tensor info. Data types supported: same as @p input1. Number of channels supported: same as @p input1.
129 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
130 */
131 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
132
133 // Inherited methods overridden:
134 MemoryRequirements workspace() const override;
135};
136} // namespace experimental
137
138/** Basic function to run @ref NEPixelWiseMultiplicationKernel */
139class NEPixelWiseMultiplication : public IFunction
140{
141public:
142 /** Default Constructor */
143 NEPixelWiseMultiplication();
144 /** Default Destructor */
145 ~NEPixelWiseMultiplication();
146 /** Prevent instances of this class from being copied (As this class contains pointers) */
147 NEPixelWiseMultiplication(const NEPixelWiseMultiplication &) = delete;
148 /** Default move constructor */
149 NEPixelWiseMultiplication(NEPixelWiseMultiplication &&);
150 /** Prevent instances of this class from being copied (As this class contains pointers) */
151 NEPixelWiseMultiplication &operator=(const NEPixelWiseMultiplication &) = delete;
152 /** Default move assignment operator */
153 NEPixelWiseMultiplication &operator=(NEPixelWiseMultiplication &&);
154 /** Initialise the kernel's inputs, output and convertion policy.
155 *
156 * @note For @p scale equal to 1/255 only round to nearest even (implemented as round half up) is supported.
157 * For all other scale values only round to zero (implemented as round towards minus infinity) is supported.
158 *
159 * @param[in, out] input1 An input tensor. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/F32
160 * This input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
161 * @param[in, out] input2 An input tensor. Data types supported: U8, QASYMM8 (only if @p input1 is QASYMM8), QASYMM8_SIGNED (only if @p input1 is QASYMM8_SIGNED), S16, QSYMM16 (only if @p input1 is QSYMM16), F16 (only if @p input1 is F16), F32 (only if @p input1 is F32).
162 * This input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
163 * @param[out] output Output tensor. Data types supported:
164 * - U8, only if both inputs are U8.
165 * - QASYMM8, only if both inputs are QASYMM8.
166 * - QASYMM8_SIGNED, only if @p input1 is QASYMM8_SIGNED.
167 * - S16.
168 * - QSYMM16, only if both inputs are QSYMM16.
169 * - S32, only if both inputs are QSYMM16.
170 * - F16, only if @p input1 is F16.
171 * - F32, only if both inputs are F32.
172 * @param[in] scale Scale to apply after multiplication.
173 * Scale must be positive and its value must be either 1/255 or 1/2^n where n is between 0 and 15.
174 * @param[in] overflow_policy Overflow policy. ConvertPolicy cannot be WRAP if datatype is QASYMM8, QASYMM8_SIGNED or QSYMM16.
175 * @param[in] rounding_policy Rounding policy.
176 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
177 */
178 void configure(const ITensor *input1, const ITensor *input2, ITensor *output, float scale, ConvertPolicy overflow_policy, RoundingPolicy rounding_policy,
179 const ActivationLayerInfo &act_info = ActivationLayerInfo());
180 /** Static function to check if given info will lead to a valid configuration of @ref NEPixelWiseMultiplication
181 *
182 * @note For @p scale equal to 1/255 only round to nearest even (implemented as round half up) is supported.
183 * For all other scale values only round to zero (implemented as round towards minus infinity) is supported.
184 *
185 * @param[in] input1 An input tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/F32
186 * @param[in] input2 An input tensor info. Data types supported: U8, QASYMM8 (only if @p input1 is QASYMM8), QASYMM8_SIGNED (only if @p input1 is QASYMM8_SIGNED), S16, QSYMM16 (only if both inputs are QSYMM16), F16 (only if @p input1 is F16), F32 (only if @p input1 is F32).
187 * @param[in] output Output tensor info. Data types supported:
188 * - U8, only if both inputs are U8.
189 * - QASYMM8, only if both inputs are QASYMM8.
190 * - QASYMM8_SIGNED, only if @p input1 is QASYMM8_SIGNED.
191 * - S16.
192 * - QSYMM16, only if both inputs are QSYMM16.
193 * - S32, only if both inputs are QSYMM16.
194 * - F16, only if @p input1 is F16.
195 * - F32, only if both inputs are F32.
196 * @param[in] scale Scale to apply after multiplication.
197 * Scale must be positive and its value must be either 1/255 or 1/2^n where n is between 0 and 15.
198 * @param[in] overflow_policy Overflow policy. ConvertPolicy cannot be WRAP if datatype is QASYMM8, QASYMM8_SIGNED or QSYMM16.
199 * @param[in] rounding_policy Rounding policy.
200 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
201 *
202 * @return a status
203 */
204 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, float scale, ConvertPolicy overflow_policy, RoundingPolicy rounding_policy,
205 const ActivationLayerInfo &act_info = ActivationLayerInfo());
206
207 // Inherited methods overridden:
208 void run() override;
209
210private:
211 struct Impl;
212 std::unique_ptr<Impl> _impl;
213};
214
215/** Basic function to run @ref NEComplexPixelWiseMultiplicationKernel. */
216class NEComplexPixelWiseMultiplication : public IFunction
217{
218public:
219 /** Default Constructor */
220 NEComplexPixelWiseMultiplication();
221 /** Default Destructor */
222 ~NEComplexPixelWiseMultiplication();
223 /** Prevent instances of this class from being copied (As this class contains pointers) */
224 NEComplexPixelWiseMultiplication(const NEComplexPixelWiseMultiplication &) = delete;
225 /** Default move constructor */
226 NEComplexPixelWiseMultiplication(NEComplexPixelWiseMultiplication &&);
227 /** Prevent instances of this class from being copied (As this class contains pointers) */
228 NEComplexPixelWiseMultiplication &operator=(const NEComplexPixelWiseMultiplication &) = delete;
229 /** Default move assignment operator */
230 NEComplexPixelWiseMultiplication &operator=(NEComplexPixelWiseMultiplication &&);
231 /** Initialise the kernel's inputs, output.
232 *
233 * @param[in, out] input1 An input tensor. Data types supported: F32. Number of channels supported: 2 (complex tensor).
234 * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
235 * @param[in, out] input2 An input tensor. Data types supported: same as @p input1. Number of channels supported: same as @p input1.
236 * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
237 * @param[out] output The output tensor. Data types supported: same as @p input1. Number of channels: same as @p input1.
238 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
239 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000240 void configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
giuros01154bc1c2019-03-26 17:44:40 +0000241 /** Static function to check if given info will lead to a valid configuration of @ref NEComplexPixelWiseMultiplication
242 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000243 * @param[in] input1 An input tensor info. Data types supported: F32. Number of channels supported: 2 (complex tensor).
244 * @param[in] input2 An input tensor info. Data types supported: same as @p input1. Number of channels supported: same as @p input1.
245 * @param[in] output The output tensor info. Data types supported: same as @p input1. Number of channels supported: same as @p input1.
246 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
giuros01154bc1c2019-03-26 17:44:40 +0000247 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000248 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Michalis Spyrou6eb73452020-07-02 17:39:25 +0100249
250 // Inherited methods overridden:
251 void run() override;
252
253private:
254 struct Impl;
255 std::unique_ptr<Impl> _impl;
giuros01154bc1c2019-03-26 17:44:40 +0000256};
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100257}
Michalis Spyrouf4643372019-11-29 16:17:13 +0000258#endif /*ARM_COMPUTE_NEPIXELWISEMULTIPLICATION_H */