blob: 4a0911ec4e4bd1e0beafd19f3ad6520c8a3a428c [file] [log] [blame]
giuros01164a2722018-11-20 18:34:46 +00001/*
2 * Copyright (c) 2018 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, ARI SING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24#ifndef __ARM_COMPUTE_CLELEMENTWISEOPERATIONS_H__
25#define __ARM_COMPUTE_CLELEMENTWISEOPERATIONS_H__
26
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 *
36 * @note The tensor data type for the inputs must be U8/QASYMM8/S16/S32/U32/F16/F32.
37 * @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 *
44 * @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/S16/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), 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), S16/F16/F32.
49 * @param[in] policy Policy to use to handle overflow.
50 */
51 void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, ConvertPolicy policy);
52 /** Static function to check if given info will lead to a valid configuration of @ref CLSaturatedArithmeticOperationKernel for addition
53 *
54 * @param[in] input1 First tensor input info. Data types supported: U8/QASYMM8/S16/S32/U32/F16/F32.
55 * @param[in] input2 Second tensor input info. Data types supported: U8, QASYMM8 (only if @p input1 is QASYMM8), S16/F16/F32.
56 * @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.
57 * @param[in] policy Policy to use to handle overflow.
58 *
59 * @return a status
60 */
61 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ConvertPolicy policy);
62};
63
64/** Basic function to run @ref CLSaturatedArithmeticOperationKernel for subtraction
65 *
66 * @note The tensor data type for the inputs must be U8/QASYMM8/S16/S32/U32/F16/F32.
67 * @note The function performs an arithmetic subtraction between two tensors.
68 */
69class CLArithmeticSubtraction : public ICLSimpleFunction
70{
71public:
72 /** Initialise the kernel's inputs, output and conversion policy.
73 *
74 * @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/S16/S32/U32/F16/F32.
75 * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
76 * @param[in, out] input2 Second tensor input. Data types supported: U8, QASYMM8 (only if @p input1 is QASYMM8), S16/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[out] output Output tensor. Data types supported: U8 (Only if both inputs are U8), QASYMM8 (only if both inputs are QASYMM8), S16/F16/F32.
79 * @param[in] policy Policy to use to handle overflow.
80 */
81 void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, ConvertPolicy policy);
82 /** Static function to check if given info will lead to a valid configuration of @ref CLSaturatedArithmeticOperationKernel for subtraction
83 *
84 * @param[in] input1 First tensor input info. Data types supported: U8/QASYMM8/S16/S32/U32/F16/F32.
85 * @param[in] input2 Second tensor input info. Data types supported: U8, QASYMM8 (only if @p input1 is QASYMM8), S16/F16/F32.
86 * @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.
87 * @param[in] policy Policy to use to handle overflow.
88 *
89 * @return a status
90 */
91 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ConvertPolicy policy);
92};
93
94/** Basic function to run @ref CLSaturatedArithmeticOperationKernel for division
95 *
96 * @note The tensor data type for the inputs must be F16/F32.
97 * @note The function performs an arithmetic division between two tensors.
98 */
99class CLArithmeticDivision : public ICLSimpleFunction
100{
101public:
102 /** Initialise the kernel's inputs, output.
103 *
104 * @param[in, out] input1 First tensor input. Data types supported: F16/F32.
105 * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
106 * @param[in, out] input2 Second tensor input. Same as @p input1.
107 * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
108 * @param[out] output Output tensor. Data types supported: Same as @p input1.
109 */
110 void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output);
111 /** Static function to check if given info will lead to a valid configuration of @ref CLArithmeticDivision
112 *
113 * @param[in] input1 First tensor input info. Data types supported: F16/F32.
114 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
115 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
116 *
117 * @return a status
118 */
119 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output);
120};
121
122/** Basic function to run @ref CLArithmeticOperationKernel for max
123 *
124 * @note The tensor data type for the inputs must be U8/QASYMM8/S16/S32/U32/F16/F32.
125 * @note The function performs a max operation between two tensors.
126 */
127class CLElementwiseMax : public ICLSimpleFunction
128{
129public:
130 /** Initialise the kernel's inputs, output and conversion policy.
131 *
132 * @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/S16/S32/U32/F16/F32.
133 * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
134 * @param[in, out] input2 Second tensor input. Data types supported: U8, QASYMM8 (only if @p input1 is QASYMM8), S16/F16/F32.
135 * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
136 * @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.
137 */
138 void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output);
139 /** Static function to check if given info will lead to a valid configuration of @ref CLArithmeticOperationKernel for max
140 *
141 * @param[in] input1 First tensor input info. Data types supported: U8/QASYMM8/S16/S32/U32/F16/F32.
142 * @param[in] input2 Second tensor input info. Data types supported: U8, QASYMM8 (only if @p input1 is QASYMM8), S16/F16/F32.
143 * @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.
144 *
145 * @return a status
146 */
147 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output);
148};
149
150/** Basic function to run @ref CLArithmeticOperationKernel for min
151 *
152 * @note The tensor data type for the inputs must be U8/QASYMM8/S16/S32/U32/F16/F32.
153 * @note The function performs a max operation between two tensors.
154 */
155class CLElementwiseMin : public ICLSimpleFunction
156{
157public:
158 /** Initialise the kernel's inputs, output and conversion policy.
159 *
160 * @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/S16/S32/U32/F16/F32.
161 * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
162 * @param[in, out] input2 Second tensor input. Data types supported: U8, QASYMM8 (only if @p input1 is QASYMM8), S16/F16/F32.
163 * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
164 * @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.
165 */
166 void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output);
167 /** Static function to check if given info will lead to a valid configuration of @ref CLArithmeticOperationKernel for min
168 *
169 * @param[in] input1 First tensor input info. Data types supported: U8/QASYMM8/S16/S32/U32/F16/F32.
170 * @param[in] input2 Second tensor input info. Data types supported: U8, QASYMM8 (only if @p input1 is QASYMM8), S16/F16/F32.
171 * @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.
172 *
173 * @return a status
174 */
175 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output);
176};
177
178/** Basic function to run @ref CLArithmeticOperationKernel for squared difference
179 *
180 * @note The tensor data type for the inputs must be QASYMM8/U8/S16/F16/F32.
181 * @note The function performs a squared different operation between two tensors (i.e., out[i] = (in1[i] - in2[i])^2
182 */
183class CLElementwiseSquaredDiff : public ICLSimpleFunction
184{
185public:
186 /** Initialise the kernel's inputs, output and conversion policy.
187 *
188 * @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/S16/F16/F32.
189 * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
190 * @param[in, out] input2 Second tensor input. Data types supported: U8, QASYMM8 (only if @p input1 is QASYMM8), S16/F16/F32.
191 * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
192 * @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.
193 */
194 void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output);
195 /** Static function to check if given info will lead to a valid configuration of @ref CLArithmeticOperationKernel for squared difference
196 *
197 * @param[in] input1 First tensor input info. Data types supported: U8/QASYMM8/S16/F16/F32.
198 * @param[in] input2 Second tensor input info. Data types supported: U8, QASYMM8 (only if @p input1 is QASYMM8), S16/F16/F32.
199 * @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.
200 *
201 * @return a status
202 */
203 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output);
204};
205} // namespace arm_compute
206#endif /* __ARM_COMPUTE_CLELEMENTWISEOPERATIONS_H__ */