blob: cac105cdb935f6ac9fe7066f899ae520304a11a9 [file] [log] [blame]
giuros0192fd9432018-12-03 17:30:00 +00001/*
morgolocka3598052019-12-31 12:20:47 +00002 * Copyright (c) 2018-2020 ARM Limited.
giuros0192fd9432018-12-03 17:30:00 +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
George Wortd88590f2018-12-12 17:39:58 +000017 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
giuros0192fd9432018-12-03 17:30:00 +000018 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
George Wortd88590f2018-12-12 17:39:58 +000019 * 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,
giuros0192fd9432018-12-03 17:30:00 +000021 * 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_NEELEMENTWISEOPERATIONS_H
25#define ARM_COMPUTE_NEELEMENTWISEOPERATIONS_H
giuros0192fd9432018-12-03 17:30:00 +000026
27#include "arm_compute/core/Types.h"
28#include "arm_compute/runtime/NEON/INESimpleFunction.h"
29
30namespace arm_compute
31{
32class ITensor;
33
34/** Basic function to run @ref NEArithmeticOperationKernel for max
35 *
morgolock6427c822020-01-13 11:53:20 +000036 * @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
giuros0192fd9432018-12-03 17:30:00 +000037 * @note The function performs a max operation between two tensors.
38 */
39class NEElementwiseMax : public INESimpleFunction
40{
41public:
42 /** Initialise the kernel's inputs, output and conversion policy.
43 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000044 * @param[in, out] input1 First tensor input. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
45 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
46 * @param[out] output Output tensor. Data types supported: Same as @p input1.
47 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
giuros0192fd9432018-12-03 17:30:00 +000048 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000049 void configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
giuros0192fd9432018-12-03 17:30:00 +000050 /** Static function to check if given info will lead to a valid configuration of @ref NEArithmeticOperationKernel for max
51 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000052 * @param[in] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
53 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
54 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
55 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
giuros0192fd9432018-12-03 17:30:00 +000056 *
57 * @return a status
58 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000059 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
giuros0192fd9432018-12-03 17:30:00 +000060};
61
62/** Basic function to run @ref NEArithmeticOperationKernel for min
63 *
morgolock6427c822020-01-13 11:53:20 +000064 * @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
65 * @note The function performs a min operation between two tensors.
giuros0192fd9432018-12-03 17:30:00 +000066 */
67class NEElementwiseMin : public INESimpleFunction
68{
69public:
70 /** Initialise the kernel's inputs, output and conversion policy.
71 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000072 * @param[in, out] input1 First tensor input. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
73 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
74 * @param[out] output Output tensor. Data types supported: Same as @p input1.
75 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
giuros0192fd9432018-12-03 17:30:00 +000076 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000077 void configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
giuros0192fd9432018-12-03 17:30:00 +000078 /** Static function to check if given info will lead to a valid configuration of @ref NEArithmeticOperationKernel for min
79 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000080 * @param[in] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
81 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
82 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
83 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
giuros0192fd9432018-12-03 17:30:00 +000084 *
85 * @return a status
86 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000087 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
giuros0192fd9432018-12-03 17:30:00 +000088};
89
90/** Basic function to run @ref NEArithmeticOperationKernel for squared difference
91 *
morgolock6427c822020-01-13 11:53:20 +000092 * @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
giuros0192fd9432018-12-03 17:30:00 +000093 * @note The function performs a squared different operation between two tensors (i.e., out[i] = (in1[i] - in2[i])^2
94 */
95class NEElementwiseSquaredDiff : public INESimpleFunction
96{
97public:
98 /** Initialise the kernel's inputs, output and conversion policy.
99 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000100 * @param[in, out] input1 First tensor input. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
101 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
102 * @param[out] output Output tensor. Data types supported: Same as @p input1.
103 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
giuros0192fd9432018-12-03 17:30:00 +0000104 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000105 void configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
giuros0192fd9432018-12-03 17:30:00 +0000106 /** Static function to check if given info will lead to a valid configuration of @ref NEArithmeticOperationKernel for squared difference
107 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000108 * @param[in] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
109 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
110 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
111 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
giuros0192fd9432018-12-03 17:30:00 +0000112 *
113 * @return a status
114 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000115 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
giuros0192fd9432018-12-03 17:30:00 +0000116};
George Wortd88590f2018-12-12 17:39:58 +0000117
George Worta1e7e282019-01-15 11:00:29 +0000118/** Basic function to run @ref NEArithmeticOperationKernel for division
119 *
120 * @note The tensor data type for the inputs must be F16/F32.
121 * @note The function performs a squared different operation between two tensors (i.e., out[i] = in1[i] / in2[i])
122 */
123class NEElementwiseDivision : public INESimpleFunction
124{
125public:
126 /** Initialise the kernel's inputs, output and conversion policy.
127 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000128 * @param[in, out] input1 First tensor input. Data types supported: F16/F32.
129 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
130 * @param[out] output Output tensor. Data types supported: Same as @p input1.
131 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
George Worta1e7e282019-01-15 11:00:29 +0000132 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000133 void configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
George Worta1e7e282019-01-15 11:00:29 +0000134 /** Static function to check if given info will lead to a valid configuration of @ref NEArithmeticOperationKernel for division
135 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000136 * @param[in] input1 First tensor input info. Data types supported: F16/F32.
137 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
138 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
139 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
George Worta1e7e282019-01-15 11:00:29 +0000140 *
141 * @return a status
142 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000143 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
George Worta1e7e282019-01-15 11:00:29 +0000144};
145
Usama Arif81e671e2019-05-13 13:33:14 +0100146/** Basic function to run @ref NEArithmeticOperationKernel for power
147 *
148 * @note The tensor data type for the inputs must be F16/F32.
149 * @note The function performs a elementwise power of in1 to in2 (i.e., out[i] = in1[i] ^ in2[i])
150 * @note For an exponent that is a float, this function will only work with a positive base.
151 */
152class NEElementwisePower : public INESimpleFunction
153{
154public:
155 /** Initialise the kernel's inputs, output and conversion policy.
156 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000157 * @param[in, out] input1 First tensor input. Data types supported: F16/F32.
158 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
159 * @param[out] output Output tensor. Data types supported: Same as @p input1.
160 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
Usama Arif81e671e2019-05-13 13:33:14 +0100161 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000162 void configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Usama Arif81e671e2019-05-13 13:33:14 +0100163 /** Static function to check if given info will lead to a valid configuration of @ref NEArithmeticOperationKernel for power
164 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000165 * @param[in] input1 First tensor input info. Data types supported: F16/F32.
166 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
167 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
168 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
Usama Arif81e671e2019-05-13 13:33:14 +0100169 *
170 * @return a status
171 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000172 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Usama Arif81e671e2019-05-13 13:33:14 +0100173};
174
George Worta1e7e282019-01-15 11:00:29 +0000175/** Basic function to run @ref NEComparisonOperationKernel.
George Wortd88590f2018-12-12 17:39:58 +0000176 *
morgolock74a16962020-01-15 11:40:49 +0000177 * @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
George Wortd88590f2018-12-12 17:39:58 +0000178 * @note The function performs a comparison operation between two tensors.
179 */
180class NEElementwiseComparison : public INESimpleFunction
181{
182public:
183 /** Initialise the kernel's inputs, output and conversion policy.
184 *
morgolock74a16962020-01-15 11:40:49 +0000185 * @param[in, out] input1 First tensor input. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
George Wortd88590f2018-12-12 17:39:58 +0000186 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
187 * @param[out] output Output tensor. Data types supported: U16/U32.
188 * @param[in] op Comparison Operation to be performed.
189 */
190 void configure(ITensor *input1, ITensor *input2, ITensor *output, ComparisonOperation op);
191 /** Static function to check if given info will lead to a valid configuration of @ref NEComparisonOperationKernel
192 *
morgolock74a16962020-01-15 11:40:49 +0000193 * @param[in] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
George Wortd88590f2018-12-12 17:39:58 +0000194 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
195 * @param[in] output Output tensor info. Data types supported: U16/U32.
196 * @param[in] op Comparison Operation to be performed.
197 *
198 * @return a status
199 */
200 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ComparisonOperation op);
201};
202
203/** Basic function to run @ref NEComparisonOperationKernel
204 *
morgolock74a16962020-01-15 11:40:49 +0000205 * @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
George Wortd88590f2018-12-12 17:39:58 +0000206 * @note The function performs a comparison operation between two tensors.
207 */
208template <ComparisonOperation op>
209class NEElementwiseComparisonStatic : public INESimpleFunction
210{
211public:
212 /** Initialise the kernel's inputs, output and conversion policy.
213 *
morgolock74a16962020-01-15 11:40:49 +0000214 * @param[in, out] input1 First tensor input. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
George Wortd88590f2018-12-12 17:39:58 +0000215 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
216 * @param[out] output Output tensor. Data types supported: U16/U32.
217 */
218 void configure(ITensor *input1, ITensor *input2, ITensor *output);
219 /** Static function to check if given info will lead to a valid configuration of @ref NEComparisonOperationKernel
220 *
morgolock74a16962020-01-15 11:40:49 +0000221 * @param[in] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
George Wortd88590f2018-12-12 17:39:58 +0000222 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
223 * @param[in] output Output tensor info. Data types supported: U16/U32.
224 *
225 * @return a status
226 */
227 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output);
228};
229
230/** Basic function to run equal comparison. */
231using NEEqual = NEElementwiseComparisonStatic<ComparisonOperation::Equal>;
232/** Basic function to run not equal comparison. */
233using NENotEqual = NEElementwiseComparisonStatic<ComparisonOperation::NotEqual>;
234/** Basic function to run greater comparison. */
235using NEGreater = NEElementwiseComparisonStatic<ComparisonOperation::Greater>;
236/** Basic function to run greater-equal comparison. */
237using NEGreaterEqual = NEElementwiseComparisonStatic<ComparisonOperation::GreaterEqual>;
238/** Basic function to run less comparison. */
239using NELess = NEElementwiseComparisonStatic<ComparisonOperation::Less>;
240/** Basic function to run less-equal comparison. */
241using NELessEqual = NEElementwiseComparisonStatic<ComparisonOperation::LessEqual>;
giuros0192fd9432018-12-03 17:30:00 +0000242} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +0000243#endif /* ARM_COMPUTE_NEELEMENTWISEOPERATIONS_H */