Sang-Hoon Park | 75eea33 | 2020-11-13 13:44:13 +0000 | [diff] [blame] | 1 | /* |
Michele Di Giorgio | 1e0208a | 2021-01-22 15:42:59 +0000 | [diff] [blame] | 2 | * Copyright (c) 2020-2021 Arm Limited. |
Sang-Hoon Park | 75eea33 | 2020-11-13 13:44:13 +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 | */ |
| 24 | #ifndef ARM_COMPUTE_CLLOGICALAND_H |
| 25 | #define ARM_COMPUTE_CLLOGICALAND_H |
| 26 | |
| 27 | #include "arm_compute/core/Error.h" |
| 28 | #include "arm_compute/runtime/CL/ICLOperator.h" |
| 29 | #include "arm_compute/runtime/IFunction.h" |
| 30 | |
| 31 | namespace arm_compute |
| 32 | { |
| 33 | class CLCompileContext; |
| 34 | class ICLTensor; |
| 35 | class ITensorInfo; |
| 36 | |
Michele Di Giorgio | 1e0208a | 2021-01-22 15:42:59 +0000 | [diff] [blame] | 37 | /** Basic function to run @ref arm_compute::opencl::kernels::ClLogicalBinaryKernel. |
Sang-Hoon Park | 75eea33 | 2020-11-13 13:44:13 +0000 | [diff] [blame] | 38 | * |
| 39 | * @note The tensor data type for the inputs must be U8. |
| 40 | * @note The function performs a logical AND operation using the two input tensors. |
| 41 | */ |
| 42 | class CLLogicalAnd : public IFunction |
| 43 | { |
| 44 | public: |
| 45 | /** Default Constructor */ |
| 46 | CLLogicalAnd(); |
| 47 | /** Default Destructor */ |
| 48 | ~CLLogicalAnd(); |
| 49 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 50 | CLLogicalAnd(const CLLogicalAnd &) = delete; |
| 51 | /** Default move constructor */ |
| 52 | CLLogicalAnd(CLLogicalAnd &&); |
| 53 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 54 | CLLogicalAnd &operator=(const CLLogicalAnd &) = delete; |
| 55 | /** Default move assignment operator */ |
| 56 | CLLogicalAnd &operator=(CLLogicalAnd &&); |
| 57 | /** Initialize the function |
| 58 | * |
Sheri Zhang | 6124ce6 | 2021-05-04 14:03:13 +0100 | [diff] [blame] | 59 | * Valid data layouts: |
| 60 | * - All |
| 61 | * |
| 62 | * Valid data type configurations: |
| 63 | * |src0 |src1 |dst | |
| 64 | * |:--------------|:-------------|:------------| |
| 65 | * |U8 |U8 |U8 | |
| 66 | * |
Sang-Hoon Park | 75eea33 | 2020-11-13 13:44:13 +0000 | [diff] [blame] | 67 | * @param[in] input1 Input tensor. Data types supported: U8. |
Sang-Hoon Park | 2dbc586 | 2020-11-18 13:52:11 +0000 | [diff] [blame] | 68 | * @param[in] input2 Input tensor. Data types supported: same as @p input1. |
| 69 | * @param[out] output Output tensor. Data types supported: same as @p input1. |
Sang-Hoon Park | 75eea33 | 2020-11-13 13:44:13 +0000 | [diff] [blame] | 70 | */ |
| 71 | void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output); |
| 72 | /** Initialize the function |
| 73 | * |
| 74 | * @param[in] compile_context The compile context to be used. |
| 75 | * @param[in] input1 Input tensor. Data types supported: U8. |
Sang-Hoon Park | 2dbc586 | 2020-11-18 13:52:11 +0000 | [diff] [blame] | 76 | * @param[in] input2 Input tensor. Data types supported: same as @p input1. |
| 77 | * @param[out] output Output tensor. Data types supported: same as @p input1. |
Sang-Hoon Park | 75eea33 | 2020-11-13 13:44:13 +0000 | [diff] [blame] | 78 | */ |
| 79 | void configure(const CLCompileContext &compile_context, ICLTensor *input1, ICLTensor *input2, ICLTensor *output); |
| 80 | /** Static function to check if given info will lead to a valid configuration |
| 81 | * |
| 82 | * @param[in] input1 First tensor input info. Data types supported: U8. |
Sang-Hoon Park | 2dbc586 | 2020-11-18 13:52:11 +0000 | [diff] [blame] | 83 | * @param[in] input2 Second tensor input info. Data types supported: same as @p input1. |
| 84 | * @param[in] output Output tensor info. Data types supported: same as @p input1. |
Sang-Hoon Park | 75eea33 | 2020-11-13 13:44:13 +0000 | [diff] [blame] | 85 | * |
| 86 | * @return a status |
| 87 | */ |
| 88 | static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output); |
| 89 | |
| 90 | // Inherited methods overridden: |
| 91 | void run() override; |
| 92 | |
| 93 | private: |
| 94 | struct Impl; |
| 95 | std::unique_ptr<Impl> _impl; |
| 96 | }; |
Georgios Pinitas | 856f66e | 2021-04-22 21:13:21 +0100 | [diff] [blame] | 97 | |
| 98 | namespace experimental |
| 99 | { |
| 100 | class CLLogicalAnd : public ICLOperator |
| 101 | { |
| 102 | public: |
| 103 | /** Default Constructor */ |
| 104 | CLLogicalAnd() = default; |
| 105 | /** Initialise the kernel's inputs, output and conversion policy. |
| 106 | * |
| 107 | * @param[in] compile_context The compile context to be used. |
| 108 | * @param[in, out] input1 First tensor input. Data types supported: U8. |
| 109 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
| 110 | * @param[in, out] input2 Second tensor input. Data types supported: same as @p input1. |
| 111 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
| 112 | * @param[out] output Output tensor. Data types supported: same as @p input1. |
| 113 | */ |
| 114 | void configure(const CLCompileContext &compile_context, ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output); |
| 115 | /** Static function to check if given info will lead to a valid configuration of @ref arm_compute::opencl::kernels::ClLogicalBinaryKernel |
| 116 | * |
| 117 | * @param[in] input1 First tensor input info. Data types supported: U8. |
| 118 | * @param[in] input2 Second tensor input info. Data types supported: same as @p input1. |
| 119 | * @param[in] output Output tensor info. Data types supported: same as @p input1. |
| 120 | * |
| 121 | * @return a status |
| 122 | */ |
| 123 | static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output); |
| 124 | // Inherited methods overridden: |
| 125 | void run(ITensorPack &tensors) override; |
| 126 | }; |
| 127 | } // namespace experimental |
Sang-Hoon Park | 75eea33 | 2020-11-13 13:44:13 +0000 | [diff] [blame] | 128 | } // namespace arm_compute |
| 129 | #endif /* ARM_COMPUTE_CLLOGICALAND_H */ |