Georgios Pinitas | 7900a9e | 2018-11-23 11:44:58 +0000 | [diff] [blame] | 1 | /* |
Viet-Hoa Do | 95d477e | 2023-10-10 15:10:37 +0100 | [diff] [blame] | 2 | * Copyright (c) 2018-2020, 2023 Arm Limited. |
Georgios Pinitas | 7900a9e | 2018-11-23 11:44:58 +0000 | [diff] [blame] | 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 | */ |
Viet-Hoa Do | 95d477e | 2023-10-10 15:10:37 +0100 | [diff] [blame] | 24 | #ifndef ACL_SRC_CORE_CL_KERNELS_CLCOMPARISONKERNEL_H |
| 25 | #define ACL_SRC_CORE_CL_KERNELS_CLCOMPARISONKERNEL_H |
Georgios Pinitas | 7900a9e | 2018-11-23 11:44:58 +0000 | [diff] [blame] | 26 | |
Georgios Pinitas | 7900a9e | 2018-11-23 11:44:58 +0000 | [diff] [blame] | 27 | #include "arm_compute/core/Types.h" |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 28 | |
Sang-Hoon Park | bef7fa2 | 2020-10-21 15:58:54 +0100 | [diff] [blame] | 29 | #include "src/core/CL/ICLKernel.h" |
Georgios Pinitas | 7900a9e | 2018-11-23 11:44:58 +0000 | [diff] [blame] | 30 | |
| 31 | namespace arm_compute |
| 32 | { |
| 33 | // Forward declarations |
| 34 | class ICLTensor; |
| 35 | |
| 36 | /** Interface for the comparison kernel. */ |
| 37 | class CLComparisonKernel : public ICLKernel |
| 38 | { |
| 39 | public: |
| 40 | /** Default constructor. */ |
| 41 | CLComparisonKernel(); |
| 42 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 43 | CLComparisonKernel(const CLComparisonKernel &) = delete; |
| 44 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 45 | CLComparisonKernel &operator=(const CLComparisonKernel &) = delete; |
| 46 | /** Allow instances of this class to be moved */ |
| 47 | CLComparisonKernel(CLComparisonKernel &&) = default; |
| 48 | /** Allow instances of this class to be moved */ |
| 49 | CLComparisonKernel &operator=(CLComparisonKernel &&) = default; |
| 50 | /** Default destructor */ |
| 51 | ~CLComparisonKernel() = default; |
| 52 | /** Set the inputs and output tensors |
| 53 | * |
Michele Di Giorgio | cbbed28 | 2019-12-20 13:26:08 +0000 | [diff] [blame] | 54 | * @param[in] input1 Source tensor. Data types supported: All. |
Georgios Pinitas | 7900a9e | 2018-11-23 11:44:58 +0000 | [diff] [blame] | 55 | * @param[in] input2 Source tensor. Data types supported: Same as @p input1. |
| 56 | * @param[out] output Destination tensor. Data types supported: U8. |
| 57 | * @param[in] operation Comparison operation to use. |
| 58 | */ |
| 59 | void configure(const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output, ComparisonOperation operation); |
Manuel Bottini | 4c6bd51 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 60 | /** Set the inputs and output tensors |
| 61 | * |
| 62 | * @param[in] compile_context The compile context to be used. |
| 63 | * @param[in] input1 Source tensor. Data types supported: All. |
| 64 | * @param[in] input2 Source tensor. Data types supported: Same as @p input1. |
| 65 | * @param[out] output Destination tensor. Data types supported: U8. |
| 66 | * @param[in] operation Comparison operation to use. |
| 67 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 68 | void configure(const CLCompileContext &compile_context, |
| 69 | const ICLTensor *input1, |
| 70 | const ICLTensor *input2, |
| 71 | ICLTensor *output, |
| 72 | ComparisonOperation operation); |
Georgios Pinitas | 7900a9e | 2018-11-23 11:44:58 +0000 | [diff] [blame] | 73 | /** Static function to check if given info will lead to a valid configuration of @ref CLComparisonKernel |
| 74 | * |
Michele Di Giorgio | cbbed28 | 2019-12-20 13:26:08 +0000 | [diff] [blame] | 75 | * @param[in] input1 Source tensor. Data types supported: All. |
Georgios Pinitas | 7900a9e | 2018-11-23 11:44:58 +0000 | [diff] [blame] | 76 | * @param[in] input2 Source tensor. Data types supported: Same as @p input1. |
| 77 | * @param[in] output Destination tensor. Data types supported: U8. |
| 78 | * @param[in] operation Comparison operation to use. |
| 79 | * |
| 80 | * @return a status |
| 81 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 82 | static Status validate(const ITensorInfo *input1, |
| 83 | const ITensorInfo *input2, |
| 84 | const ITensorInfo *output, |
| 85 | ComparisonOperation operation); |
Georgios Pinitas | 7900a9e | 2018-11-23 11:44:58 +0000 | [diff] [blame] | 86 | |
| 87 | // Inherited methods overridden: |
Viet-Hoa Do | 95d477e | 2023-10-10 15:10:37 +0100 | [diff] [blame] | 88 | void run(const Window &window, cl::CommandQueue &queue) override; |
Georgios Pinitas | 7900a9e | 2018-11-23 11:44:58 +0000 | [diff] [blame] | 89 | |
| 90 | private: |
| 91 | const ICLTensor *_input1; /**< Source tensor 1 */ |
| 92 | const ICLTensor *_input2; /**< Source tensor 2 */ |
| 93 | ICLTensor *_output; /**< Destination tensor */ |
| 94 | }; |
| 95 | } // namespace arm_compute |
Viet-Hoa Do | 95d477e | 2023-10-10 15:10:37 +0100 | [diff] [blame] | 96 | #endif // ACL_SRC_CORE_CL_KERNELS_CLCOMPARISONKERNEL_H |