blob: 7f0b22341f0fc3944091da72199006371170b06a [file] [log] [blame]
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001/*
Michalis Spyrouf4643372019-11-29 16:17:13 +00002 * Copyright (c) 2018-2019 ARM Limited.
Georgios Pinitas7900a9e2018-11-23 11:44:58 +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
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_CLCOMPARISON_H
25#define ARM_COMPUTE_CLCOMPARISON_H
Georgios Pinitas7900a9e2018-11-23 11:44:58 +000026
27#include "arm_compute/core/Types.h"
28#include "arm_compute/runtime/CL/ICLSimpleFunction.h"
29
30namespace arm_compute
31{
32// Forward declarations
33class ICLTensor;
34
35/** Basic function to run @ref CLComparisonKernel */
36class CLComparison : public ICLSimpleFunction
37{
38public:
39 /** Initialise the kernel's inputs and outputs.
40 *
41 * @param[in] input1 Source tensor. Data types supported: U8/S8/QASYMM8/U16/S16/U32/S32/F16/F32.
42 * The input1 tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
43 * @param[in] input2 Source tensor. Data types supported: Same as @p input1.
44 * The input2 tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
45 * @param[out] output Destination tensor. Data types supported: U8.
46 * @param[out] operation Comparison operation to be used.
47 */
48 void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, ComparisonOperation operation);
49 /** Static function to check if given info will lead to a valid configuration of @ref CLComparison
50 *
51 * @param[in] input1 Source tensor. Data types supported: U8/S8/QASYMM8/U16/S16/U32/S32/F16/F32.
52 * @param[in] input2 Source tensor. Data types supported: Same as @p input1.
53 * @param[in] output Destination tensor. Data types supported: U8.
54 * @param[out] operation Comparison operation to be used.
55 *
56 * @return a status
57 */
58 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ComparisonOperation operation);
59};
60
61/** Basic function to run @ref CLComparisonKernel */
62template <ComparisonOperation COP>
63class CLComparisonStatic : public ICLSimpleFunction
64{
65public:
66 static constexpr ComparisonOperation operation = COP; /** Comparison operations used by the class */
67
68public:
69 /** Initialise the kernel's inputs and outputs.
70 *
71 * @param[in] input1 Source tensor. Data types supported: U8/S8/QASYMM8/U16/S16/U32/S32/F16/F32.
72 * The input1 tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
73 * @param[in] input2 Source tensor. Data types supported: Same as @p input1.
74 * The input2 tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
75 * @param[out] output Destination tensor. Data types supported: U8.
76 */
77 void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output);
78 /** Static function to check if given info will lead to a valid configuration of @ref CLComparison
79 *
80 * @param[in] input1 Source tensor. Data types supported: U8/S8/QASYMM8/U16/S16/U32/S32/F16/F32.
81 * @param[in] input2 Source tensor. Data types supported: Same as @p input1.
82 * @param[in] output Destination tensor. Data types supported: U8.
83 *
84 * @return a status
85 */
86 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output);
87};
88
89/** Basic function to run equal comparison. */
90using CLEqual = CLComparisonStatic<ComparisonOperation::Equal>;
91/** Basic function to run not equal comparison. */
92using CLNotEqual = CLComparisonStatic<ComparisonOperation::NotEqual>;
93/** Basic function to run greater comparison. */
94using CLGreater = CLComparisonStatic<ComparisonOperation::Greater>;
95/** Basic function to run greater-equal comparison. */
96using CLGreaterEqual = CLComparisonStatic<ComparisonOperation::GreaterEqual>;
97/** Basic function to run less comparison. */
98using CLLess = CLComparisonStatic<ComparisonOperation::Less>;
99/** Basic function to run less-equal comparison. */
100using CLLessEqual = CLComparisonStatic<ComparisonOperation::LessEqual>;
101} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +0000102#endif /* ARM_COMPUTE_CLCOMPARISON_H */