Compute Library
 22.05
CLComparison.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2021 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, ARISING 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_CLCOMPARISON_H
25 #define ARM_COMPUTE_CLCOMPARISON_H
26 
27 #include "arm_compute/core/Types.h"
29 
30 namespace arm_compute
31 {
32 // Forward declarations
33 class CLCompileContext;
34 class ICLTensor;
35 class ITensorInfo;
36 
37 /** Basic function to run @ref CLComparisonKernel */
39 {
40 public:
41  /** Initialise the kernel's inputs and outputs.
42  *
43  * Valid data layouts:
44  * - All
45  *
46  * Valid data type configurations:
47  * |src0 |src1 |dst |
48  * |:--------|:--------|:--------|
49  * |All |All |U8 |
50  *
51  * @param[in] input1 Source tensor. Data types supported: All.
52  * The input1 tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
53  * @param[in] input2 Source tensor. Data types supported: Same as @p input1.
54  * The input2 tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
55  * @param[out] output Destination tensor. Data types supported: U8.
56  * @param[out] operation Comparison operation to be used.
57  */
58  void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, ComparisonOperation operation);
59  /** Initialise the kernel's inputs and outputs.
60  *
61  * @param[in] compile_context The compile context to be used.
62  * @param[in] input1 Source tensor. Data types supported: All.
63  * The input1 tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
64  * @param[in] input2 Source tensor. Data types supported: Same as @p input1.
65  * The input2 tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
66  * @param[out] output Destination tensor. Data types supported: U8.
67  * @param[out] operation Comparison operation to be used.
68  */
69  void configure(const CLCompileContext &compile_context, ICLTensor *input1, ICLTensor *input2, ICLTensor *output, ComparisonOperation operation);
70  /** Static function to check if given info will lead to a valid configuration of @ref CLComparison
71  *
72  * @param[in] input1 Source tensor. Data types supported: All.
73  * @param[in] input2 Source tensor. Data types supported: Same as @p input1.
74  * @param[in] output Destination tensor. Data types supported: U8.
75  * @param[out] operation Comparison operation to be used.
76  *
77  * @return a status
78  */
79  static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ComparisonOperation operation);
80 };
81 
82 /** Basic function to run @ref CLComparisonKernel */
83 template <ComparisonOperation COP>
85 {
86 public:
87  static constexpr ComparisonOperation operation = COP; /** Comparison operations used by the class */
88 
89 public:
90  /** Initialise the kernel's inputs and outputs.
91  *
92  * @param[in] input1 Source tensor. Data types supported: All.
93  * The input1 tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
94  * @param[in] input2 Source tensor. Data types supported: Same as @p input1.
95  * The input2 tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
96  * @param[out] output Destination tensor. Data types supported: U8.
97  */
98  void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output);
99  /** Comparison operations used by the class */
100 
101 public:
102  /** Initialise the kernel's inputs and outputs.
103  *
104  * @param[in] compile_context The compile context to be used.
105  * @param[in] input1 Source tensor. Data types supported: All.
106  * The input1 tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
107  * @param[in] input2 Source tensor. Data types supported: Same as @p input1.
108  * The input2 tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
109  * @param[out] output Destination tensor. Data types supported: U8.
110  */
111  void configure(const CLCompileContext &compile_context, ICLTensor *input1, ICLTensor *input2, ICLTensor *output);
112  /** Static function to check if given info will lead to a valid configuration of @ref CLComparison
113  *
114  * @param[in] input1 Source tensor. Data types supported: All.
115  * @param[in] input2 Source tensor. Data types supported: Same as @p input1.
116  * @param[in] output Destination tensor. Data types supported: U8.
117  *
118  * @return a status
119  */
120  static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output);
121 };
122 
123 /** Basic function to run equal comparison. */
125 /** Basic function to run not equal comparison. */
127 /** Basic function to run greater comparison. */
129 /** Basic function to run greater-equal comparison. */
131 /** Basic function to run less comparison. */
133 /** Basic function to run less-equal comparison. */
135 } // namespace arm_compute
136 #endif /* ARM_COMPUTE_CLCOMPARISON_H */
void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, ComparisonOperation operation)
Initialise the kernel&#39;s inputs and outputs.
Basic function to run CLComparisonKernel.
Definition: CLComparison.h:84
Store the tensor&#39;s metadata.
Definition: ITensorInfo.h:40
Status class.
Definition: Error.h:52
Copyright (c) 2017-2022 Arm Limited.
Basic interface for functions which have a single OpenCL kernel.
ComparisonOperation
Supported comparison operations.
Definition: Types.h:173
CLCompileContext class.
static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ComparisonOperation operation)
Static function to check if given info will lead to a valid configuration of CLComparison.
Interface for OpenCL tensor.
Definition: ICLTensor.h:42
Basic function to run CLComparisonKernel.
Definition: CLComparison.h:38