blob: cd9ed24bee2ddb068c01092318f85d0eb66b494a [file] [log] [blame]
giuros0192fd9432018-12-03 17:30:00 +00001/*
George Wortd88590f2018-12-12 17:39:58 +00002 * Copyright (c) 2018-2019 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 */
24#ifndef __ARM_COMPUTE_NEELEMENTWISEOPERATIONS_H__
25#define __ARM_COMPUTE_NEELEMENTWISEOPERATIONS_H__
26
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 *
George Wortd88590f2018-12-12 17:39:58 +000036 * @note The tensor data type for the inputs must be QASYMM8/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 *
44 * @param[in, out] input1 First tensor input. Data types supported: QASYMM8/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 */
48 void configure(ITensor *input1, ITensor *input2, ITensor *output);
49 /** Static function to check if given info will lead to a valid configuration of @ref NEArithmeticOperationKernel for max
50 *
51 * @param[in] input1 First tensor input info. Data types supported: QASYMM8/S16/F16/S32/F32.
52 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
53 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
54 *
55 * @return a status
56 */
57 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output);
58};
59
60/** Basic function to run @ref NEArithmeticOperationKernel for min
61 *
George Wortd88590f2018-12-12 17:39:58 +000062 * @note The tensor data type for the inputs must be QASYMM8/S16/F16/S32/F32.
giuros0192fd9432018-12-03 17:30:00 +000063 * @note The function performs a max operation between two tensors.
64 */
65class NEElementwiseMin : public INESimpleFunction
66{
67public:
68 /** Initialise the kernel's inputs, output and conversion policy.
69 *
70 * @param[in, out] input1 First tensor input. Data types supported: QASYMM8/S16/F16/S32/F32.
71 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
72 * @param[out] output Output tensor. Data types supported: Same as @p input1.
73 */
74 void configure(ITensor *input1, ITensor *input2, ITensor *output);
75 /** Static function to check if given info will lead to a valid configuration of @ref NEArithmeticOperationKernel for min
76 *
77 * @param[in] input1 First tensor input info. Data types supported: QASYMM8/S16/F16/S32/F32.
78 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
79 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
80 *
81 * @return a status
82 */
83 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output);
84};
85
86/** Basic function to run @ref NEArithmeticOperationKernel for squared difference
87 *
George Wortd88590f2018-12-12 17:39:58 +000088 * @note The tensor data type for the inputs must be QASYMM8/S16/F16/S32/F32.
giuros0192fd9432018-12-03 17:30:00 +000089 * @note The function performs a squared different operation between two tensors (i.e., out[i] = (in1[i] - in2[i])^2
90 */
91class NEElementwiseSquaredDiff : public INESimpleFunction
92{
93public:
94 /** Initialise the kernel's inputs, output and conversion policy.
95 *
96 * @param[in, out] input1 First tensor input. Data types supported: QASYMM8/S16/F16/S32/F32.
97 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
98 * @param[out] output Output tensor. Data types supported: Same as @p input1.
99 */
100 void configure(ITensor *input1, ITensor *input2, ITensor *output);
101 /** Static function to check if given info will lead to a valid configuration of @ref NEArithmeticOperationKernel for squared difference
102 *
103 * @param[in] input1 First tensor input info. Data types supported: QASYMM8/S16/F16/S32/F32.
104 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
105 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
106 *
107 * @return a status
108 */
109 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output);
110};
George Wortd88590f2018-12-12 17:39:58 +0000111
112/** Basic function to run @ref NEComparisonOperationKernel
113 *
114 * @note The tensor data type for the inputs must be QASYMM8/S16/F16/S32/F32.
115 * @note The function performs a comparison operation between two tensors.
116 */
117class NEElementwiseComparison : public INESimpleFunction
118{
119public:
120 /** Initialise the kernel's inputs, output and conversion policy.
121 *
122 * @param[in, out] input1 First tensor input. Data types supported: QASYMM8/S16/F16/S32/F32.
123 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
124 * @param[out] output Output tensor. Data types supported: U16/U32.
125 * @param[in] op Comparison Operation to be performed.
126 */
127 void configure(ITensor *input1, ITensor *input2, ITensor *output, ComparisonOperation op);
128 /** Static function to check if given info will lead to a valid configuration of @ref NEComparisonOperationKernel
129 *
130 * @param[in] input1 First tensor input info. Data types supported: QASYMM8/S16/F16/S32/F32.
131 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
132 * @param[in] output Output tensor info. Data types supported: U16/U32.
133 * @param[in] op Comparison Operation to be performed.
134 *
135 * @return a status
136 */
137 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ComparisonOperation op);
138};
139
140/** Basic function to run @ref NEComparisonOperationKernel
141 *
142 * @note The tensor data type for the inputs must be QASYMM8/S16/F16/S32/F32.
143 * @note The function performs a comparison operation between two tensors.
144 */
145template <ComparisonOperation op>
146class NEElementwiseComparisonStatic : public INESimpleFunction
147{
148public:
149 /** Initialise the kernel's inputs, output and conversion policy.
150 *
151 * @param[in, out] input1 First tensor input. Data types supported: QASYMM8/S16/F16/S32/F32.
152 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
153 * @param[out] output Output tensor. Data types supported: U16/U32.
154 */
155 void configure(ITensor *input1, ITensor *input2, ITensor *output);
156 /** Static function to check if given info will lead to a valid configuration of @ref NEComparisonOperationKernel
157 *
158 * @param[in] input1 First tensor input info. Data types supported: QASYMM8/S16/F16/S32/F32.
159 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
160 * @param[in] output Output tensor info. Data types supported: U16/U32.
161 *
162 * @return a status
163 */
164 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output);
165};
166
167/** Basic function to run equal comparison. */
168using NEEqual = NEElementwiseComparisonStatic<ComparisonOperation::Equal>;
169/** Basic function to run not equal comparison. */
170using NENotEqual = NEElementwiseComparisonStatic<ComparisonOperation::NotEqual>;
171/** Basic function to run greater comparison. */
172using NEGreater = NEElementwiseComparisonStatic<ComparisonOperation::Greater>;
173/** Basic function to run greater-equal comparison. */
174using NEGreaterEqual = NEElementwiseComparisonStatic<ComparisonOperation::GreaterEqual>;
175/** Basic function to run less comparison. */
176using NELess = NEElementwiseComparisonStatic<ComparisonOperation::Less>;
177/** Basic function to run less-equal comparison. */
178using NELessEqual = NEElementwiseComparisonStatic<ComparisonOperation::LessEqual>;
giuros0192fd9432018-12-03 17:30:00 +0000179} // namespace arm_compute
180#endif /* __ARM_COMPUTE_NEELEMENTWISEOPERATIONS_H__ */