blob: c6d61e45f2ed42f5fc13d9d04526d22bb3171582 [file] [log] [blame]
Georgios Pinitas7900a9e2018-11-23 11:44:58 +00001/*
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01002 * Copyright (c) 2018-2020 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 *
Michele Di Giorgiocbbed282019-12-20 13:26:08 +000041 * @param[in] input1 Source tensor. Data types supported: All.
Georgios Pinitas7900a9e2018-11-23 11:44:58 +000042 * 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);
Manuel Bottini2b84be52020-04-08 10:15:51 +010049 /** Initialise the kernel's inputs and outputs.
50 *
51 * @param[in] compile_context The compile context to be used.
52 * @param[in] input1 Source tensor. Data types supported: All.
53 * The input1 tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
54 * @param[in] input2 Source tensor. Data types supported: Same as @p input1.
55 * The input2 tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
56 * @param[out] output Destination tensor. Data types supported: U8.
57 * @param[out] operation Comparison operation to be used.
58 */
59 void configure(const CLCompileContext &compile_context, ICLTensor *input1, ICLTensor *input2, ICLTensor *output, ComparisonOperation operation);
Georgios Pinitas7900a9e2018-11-23 11:44:58 +000060 /** Static function to check if given info will lead to a valid configuration of @ref CLComparison
61 *
Michele Di Giorgiocbbed282019-12-20 13:26:08 +000062 * @param[in] input1 Source tensor. Data types supported: All.
Georgios Pinitas7900a9e2018-11-23 11:44:58 +000063 * @param[in] input2 Source tensor. Data types supported: Same as @p input1.
64 * @param[in] output Destination tensor. Data types supported: U8.
65 * @param[out] operation Comparison operation to be used.
66 *
67 * @return a status
68 */
69 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ComparisonOperation operation);
70};
71
72/** Basic function to run @ref CLComparisonKernel */
73template <ComparisonOperation COP>
74class CLComparisonStatic : public ICLSimpleFunction
75{
76public:
77 static constexpr ComparisonOperation operation = COP; /** Comparison operations used by the class */
78
79public:
80 /** Initialise the kernel's inputs and outputs.
81 *
Michele Di Giorgiof6f78762020-07-06 11:27:21 +010082 * @param[in] input1 Source tensor. Data types supported: All.
Georgios Pinitas7900a9e2018-11-23 11:44:58 +000083 * The input1 tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
84 * @param[in] input2 Source tensor. Data types supported: Same as @p input1.
85 * The input2 tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
86 * @param[out] output Destination tensor. Data types supported: U8.
87 */
88 void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output);
Manuel Bottini2b84be52020-04-08 10:15:51 +010089 /** Comparison operations used by the class */
90
91public:
92 /** Initialise the kernel's inputs and outputs.
93 *
94 * @param[in] compile_context The compile context to be used.
Michele Di Giorgiof6f78762020-07-06 11:27:21 +010095 * @param[in] input1 Source tensor. Data types supported: All.
Manuel Bottini2b84be52020-04-08 10:15:51 +010096 * The input1 tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
97 * @param[in] input2 Source tensor. Data types supported: Same as @p input1.
98 * The input2 tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
99 * @param[out] output Destination tensor. Data types supported: U8.
100 */
101 void configure(const CLCompileContext &compile_context, ICLTensor *input1, ICLTensor *input2, ICLTensor *output);
Georgios Pinitas7900a9e2018-11-23 11:44:58 +0000102 /** Static function to check if given info will lead to a valid configuration of @ref CLComparison
103 *
Michele Di Giorgiof6f78762020-07-06 11:27:21 +0100104 * @param[in] input1 Source tensor. Data types supported: All.
Georgios Pinitas7900a9e2018-11-23 11:44:58 +0000105 * @param[in] input2 Source tensor. Data types supported: Same as @p input1.
106 * @param[in] output Destination tensor. Data types supported: U8.
107 *
108 * @return a status
109 */
110 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output);
111};
112
113/** Basic function to run equal comparison. */
114using CLEqual = CLComparisonStatic<ComparisonOperation::Equal>;
115/** Basic function to run not equal comparison. */
116using CLNotEqual = CLComparisonStatic<ComparisonOperation::NotEqual>;
117/** Basic function to run greater comparison. */
118using CLGreater = CLComparisonStatic<ComparisonOperation::Greater>;
119/** Basic function to run greater-equal comparison. */
120using CLGreaterEqual = CLComparisonStatic<ComparisonOperation::GreaterEqual>;
121/** Basic function to run less comparison. */
122using CLLess = CLComparisonStatic<ComparisonOperation::Less>;
123/** Basic function to run less-equal comparison. */
124using CLLessEqual = CLComparisonStatic<ComparisonOperation::LessEqual>;
125} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +0000126#endif /* ARM_COMPUTE_CLCOMPARISON_H */