blob: 6d9f3a0e970f9dff8d932567c5fc3dfbb27095e1 [file] [log] [blame]
giuros01164a2722018-11-20 18:34:46 +00001/*
Giorgio Arena8b2a7d32020-02-11 17:21:31 +00002 * 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
George Wort5a97b282018-12-21 16:21:04 +000020 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
giuros01164a2722018-11-20 18:34:46 +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_CLELEMENTWISEOPERATIONS_H
25#define ARM_COMPUTE_CLELEMENTWISEOPERATIONS_H
giuros01164a2722018-11-20 18:34:46 +000026
27#include "arm_compute/core/Types.h"
28#include "arm_compute/runtime/CL/ICLSimpleFunction.h"
29
30namespace arm_compute
31{
32class ICLTensor;
33
34/** Basic function to run @ref CLSaturatedArithmeticOperationKernel for addition
35 *
Michele Di Giorgio6997fc92019-06-18 10:23:22 +010036 * @note The tensor data type for the inputs must be U8/QASYMM8/S16/QSYMM16/S32/U32/F16/F32.
giuros01164a2722018-11-20 18:34:46 +000037 * @note The function performs an arithmetic addition between two tensors.
38 */
39class CLArithmeticAddition : public ICLSimpleFunction
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: U8/QASYMM8/S16/QSYMM16/S32/U32/F16/F32.
45 * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
46 * @param[in, out] input2 Second tensor input. Data types supported: U8, QASYMM8 (only if @p input1 is QASYMM8), QSYMM16 (only if @p input1 is QSYMM16), S16/F16/F32.
47 * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
48 * @param[out] output Output tensor. Data types supported: U8 (Only if both inputs are U8), QASYMM8 (only if both inputs are QASYMM8), QSYMM16 (only if both inputs is QSYMM16), S16/F16/F32.
49 * @param[in] policy Policy to use to handle overflow.
50 * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
giuros01164a2722018-11-20 18:34:46 +000051 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000052 void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, ConvertPolicy policy, const ActivationLayerInfo &act_info = ActivationLayerInfo());
giuros01164a2722018-11-20 18:34:46 +000053 /** Static function to check if given info will lead to a valid configuration of @ref CLSaturatedArithmeticOperationKernel for addition
54 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000055 * @param[in] input1 First tensor input info. Data types supported: U8/QASYMM8/S16/QSYMM16/S32/U32/F16/F32.
56 * @param[in] input2 Second tensor input info. Data types supported: U8, QASYMM8 (only if @p input1 is QASYMM8), QSYMM16 (only if @p input1 is QSYMM16), S16/F16/F32.
57 * @param[in] output Output tensor info. Data types supported: U8 (Only if both inputs are U8), QASYMM8 (only if both inputs are QASYMM8), QSYMM16 (only if both inputs is QSYMM16), S16/F16/F32.
58 * @param[in] policy Policy to use to handle overflow.
59 * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
giuros01164a2722018-11-20 18:34:46 +000060 *
61 * @return a status
62 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000063 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ConvertPolicy policy, const ActivationLayerInfo &act_info = ActivationLayerInfo());
giuros01164a2722018-11-20 18:34:46 +000064};
65
66/** Basic function to run @ref CLSaturatedArithmeticOperationKernel for subtraction
67 *
68 * @note The tensor data type for the inputs must be U8/QASYMM8/S16/S32/U32/F16/F32.
69 * @note The function performs an arithmetic subtraction between two tensors.
70 */
71class CLArithmeticSubtraction : public ICLSimpleFunction
72{
73public:
74 /** Initialise the kernel's inputs, output and conversion policy.
75 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000076 * @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/S16/S32/U32/F16/F32.
77 * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
78 * @param[in, out] input2 Second tensor input. Data types supported: U8, QASYMM8 (only if @p input1 is QASYMM8), S16/F16/F32.
79 * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
80 * @param[out] output Output tensor. Data types supported: U8 (Only if both inputs are U8), QASYMM8 (only if both inputs are QASYMM8), S16/F16/F32.
81 * @param[in] policy Policy to use to handle overflow.
82 * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
giuros01164a2722018-11-20 18:34:46 +000083 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000084 void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, ConvertPolicy policy, const ActivationLayerInfo &act_info = ActivationLayerInfo());
giuros01164a2722018-11-20 18:34:46 +000085 /** Static function to check if given info will lead to a valid configuration of @ref CLSaturatedArithmeticOperationKernel for subtraction
86 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000087 * @param[in] input1 First tensor input info. Data types supported: U8/QASYMM8/S16/S32/U32/F16/F32.
88 * @param[in] input2 Second tensor input info. Data types supported: U8, QASYMM8 (only if @p input1 is QASYMM8), S16/F16/F32.
89 * @param[in] output Output tensor info. Data types supported: U8 (Only if both inputs are U8), QASYMM8 ( only if both inputs are QASYMM8), S16/F16/F32.
90 * @param[in] policy Policy to use to handle overflow.
91 * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
giuros01164a2722018-11-20 18:34:46 +000092 *
93 * @return a status
94 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000095 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ConvertPolicy policy, const ActivationLayerInfo &act_info = ActivationLayerInfo());
giuros01164a2722018-11-20 18:34:46 +000096};
97
98/** Basic function to run @ref CLSaturatedArithmeticOperationKernel for division
99 *
100 * @note The tensor data type for the inputs must be F16/F32.
101 * @note The function performs an arithmetic division between two tensors.
102 */
103class CLArithmeticDivision : public ICLSimpleFunction
104{
105public:
106 /** Initialise the kernel's inputs, output.
107 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000108 * @param[in, out] input1 First tensor input. Data types supported: F16/F32.
109 * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
110 * @param[in, out] input2 Second tensor input. Same as @p input1.
111 * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
112 * @param[out] output Output tensor. Data types supported: Same as @p input1.
113 * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
giuros01164a2722018-11-20 18:34:46 +0000114 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000115 void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
giuros01164a2722018-11-20 18:34:46 +0000116 /** Static function to check if given info will lead to a valid configuration of @ref CLArithmeticDivision
117 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000118 * @param[in] input1 First tensor input info. Data types supported: F16/F32.
119 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
120 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
121 * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
giuros01164a2722018-11-20 18:34:46 +0000122 *
123 * @return a status
124 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000125 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
giuros01164a2722018-11-20 18:34:46 +0000126};
127
128/** Basic function to run @ref CLArithmeticOperationKernel for max
129 *
Michele Di Giorgio6997fc92019-06-18 10:23:22 +0100130 * @note The tensor data type for the inputs must be U8/QASYMM8/S16/QSYMM16/S32/U32/F16/F32.
giuros01164a2722018-11-20 18:34:46 +0000131 * @note The function performs a max operation between two tensors.
132 */
133class CLElementwiseMax : public ICLSimpleFunction
134{
135public:
136 /** Initialise the kernel's inputs, output and conversion policy.
137 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000138 * @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/S16/QSYMM16/S32/U32/F16/F32.
139 * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
140 * @param[in, out] input2 Second tensor input. Data types supported: U8, QASYMM8 (only if @p input1 is QASYMM8), S16, QSYMM16 (only if @p input1 is QSYMM16), F16/F32.
141 * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
142 * @param[out] output Output tensor. Data types supported: U8 (Only if both inputs are U8), QASYMM8 (only if both inputs are QASYMM8), S16, QSYMM16 (only if both inputs are QSYMM16), F16/F32.
143 * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
giuros01164a2722018-11-20 18:34:46 +0000144 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000145 void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
giuros01164a2722018-11-20 18:34:46 +0000146 /** Static function to check if given info will lead to a valid configuration of @ref CLArithmeticOperationKernel for max
147 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000148 * @param[in] input1 First tensor input info. Data types supported: U8/QASYMM8/S16/QSYMM16/S32/U32/F16/F32.
149 * @param[in] input2 Second tensor input info. Data types supported: U8, QASYMM8 (only if @p input1 is QASYMM8), S16, QSYMM16 (only if @p input1 is QSYMM16), F16/F32.
150 * @param[in] output Output tensor info. Data types supported: U8 (Only if both inputs are U8), QASYMM8 ( only if both inputs are QASYMM8), S16, QSYMM16 (only if both inputs are QSYMM16), F16/F32.
151 * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
giuros01164a2722018-11-20 18:34:46 +0000152 *
153 * @return a status
154 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000155 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
giuros01164a2722018-11-20 18:34:46 +0000156};
157
158/** Basic function to run @ref CLArithmeticOperationKernel for min
159 *
Michele Di Giorgio6997fc92019-06-18 10:23:22 +0100160 * @note The tensor data type for the inputs must be U8/QASYMM8/S16/QSYMM16/S32/U32/F16/F32.
giuros01164a2722018-11-20 18:34:46 +0000161 * @note The function performs a max operation between two tensors.
162 */
163class CLElementwiseMin : public ICLSimpleFunction
164{
165public:
166 /** Initialise the kernel's inputs, output and conversion policy.
167 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000168 * @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/S16/QSYMM16/S32/U32/F16/F32.
169 * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
170 * @param[in, out] input2 Second tensor input. Data types supported: U8, QASYMM8 (only if @p input1 is QASYMM8), S16, QSYMM16 (only if @p input1 is QSYMM16), F16/F32.
171 * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
172 * @param[out] output Output tensor. Data types supported: U8 (Only if both inputs are U8), QASYMM8 (only if both inputs are QASYMM8), S16, QSYMM16 (only if both inputs are QSYMM16), F16/F32.
173 * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
giuros01164a2722018-11-20 18:34:46 +0000174 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000175 void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
giuros01164a2722018-11-20 18:34:46 +0000176 /** Static function to check if given info will lead to a valid configuration of @ref CLArithmeticOperationKernel for min
177 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000178 * @param[in] input1 First tensor input info. Data types supported: U8/QASYMM8/S16/QSYMM16/S32/U32/F16/F32.
179 * @param[in] input2 Second tensor input info. Data types supported: U8, QASYMM8 (only if @p input1 is QASYMM8), S16, QSYMM16 (only if @p input1 is QSYMM16), F16/F32.
180 * @param[in] output Output tensor info. Data types supported: U8 (Only if both inputs are U8), QASYMM8 ( only if both inputs are QASYMM8), S16, QSYMM16 (only if both inputs are QSYMM16), F16/F32.
181 * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
giuros01164a2722018-11-20 18:34:46 +0000182 *
183 * @return a status
184 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000185 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
giuros01164a2722018-11-20 18:34:46 +0000186};
187
188/** Basic function to run @ref CLArithmeticOperationKernel for squared difference
189 *
Michele Di Giorgio6997fc92019-06-18 10:23:22 +0100190 * @note The tensor data type for the inputs must be QASYMM8/U8/S16/QSYMM16/F16/F32.
giuros01164a2722018-11-20 18:34:46 +0000191 * @note The function performs a squared different operation between two tensors (i.e., out[i] = (in1[i] - in2[i])^2
192 */
193class CLElementwiseSquaredDiff : public ICLSimpleFunction
194{
195public:
196 /** Initialise the kernel's inputs, output and conversion policy.
197 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000198 * @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/S16/QSYMM16/F16/F32.
199 * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
200 * @param[in, out] input2 Second tensor input. Data types supported: U8, QASYMM8 (only if @p input1 is QASYMM8), S16, QSYMM16 (only if @p input1 is QSYMM16), F16/F32.
201 * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
202 * @param[out] output Output tensor. Data types supported: U8 (Only if both inputs are U8), QASYMM8 (only if both inputs are QASYMM8), S16, QSYMM16 (only if both inputs are QSYMM16), F16/F32.
203 * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
giuros01164a2722018-11-20 18:34:46 +0000204 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000205 void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
giuros01164a2722018-11-20 18:34:46 +0000206 /** Static function to check if given info will lead to a valid configuration of @ref CLArithmeticOperationKernel for squared difference
207 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000208 * @param[in] input1 First tensor input info. Data types supported: U8/QASYMM8/S16/QSYMM16/F16/F32.
209 * @param[in] input2 Second tensor input info. Data types supported: U8, QASYMM8 (only if @p input1 is QASYMM8), S16, QSYMM16 (only if @p input1 is QSYMM16), F16/F32.
210 * @param[in] output Output tensor info. Data types supported: U8 (Only if both inputs are U8), QASYMM8 ( only if both inputs are QASYMM8), S16, QSYMM16 (only if both inputs are QSYMM16), F16/F32.
211 * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
giuros01164a2722018-11-20 18:34:46 +0000212 *
213 * @return a status
214 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000215 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
giuros01164a2722018-11-20 18:34:46 +0000216};
Usama Arif52c54f62019-05-14 10:22:36 +0100217
218/** Basic function to run @ref CLArithmeticOperationKernel for power
219 *
220 * @note The tensor data type for the inputs must be F16/F32.
221 * @note The function performs an elementwise power of in1 to in2 (i.e., out[i] = in1[i] ^ in2[i])
222 */
223class CLElementwisePower : public ICLSimpleFunction
224{
225public:
226 /** Initialise the kernel's inputs, output and conversion policy.
227 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000228 * @param[in, out] input1 First tensor input. Data types supported: F16/F32.
229 * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
230 * @param[in, out] input2 Second tensor input. Data types supported: F16/F32.
231 * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
232 * @param[out] output Output tensor. Data types supported:F16/F32.
233 * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
Usama Arif52c54f62019-05-14 10:22:36 +0100234 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000235 void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Usama Arif52c54f62019-05-14 10:22:36 +0100236 /** Static function to check if given info will lead to a valid configuration of @ref CLArithmeticOperationKernel for power
237 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000238 * @param[in] input1 First tensor input info. Data types supported: F16/F32.
239 * @param[in] input2 Second tensor input info. Data types supported: F16/F32.
240 * @param[in] output Output tensor info. Data types supported: F16/F32.
241 * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
Usama Arif52c54f62019-05-14 10:22:36 +0100242 *
243 * @return a status
244 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000245 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Usama Arif52c54f62019-05-14 10:22:36 +0100246};
giuros01164a2722018-11-20 18:34:46 +0000247} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +0000248#endif /* ARM_COMPUTE_CLELEMENTWISEOPERATIONS_H */