Compute Library
 23.05
CLLogicalOr.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020-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_CLLOGICALOR_H
25 #define ARM_COMPUTE_CLLOGICALOR_H
26 
27 #include "arm_compute/core/Error.h"
30 
31 namespace arm_compute
32 {
33 class CLCompileContext;
34 class ICLTensor;
35 class ITensorInfo;
36 
37 /** Basic function to run @ref arm_compute::opencl::kernels::ClLogicalBinaryKernel.
38  *
39  * @note The tensor data type for the inputs must be U8.
40  * @note The function performs a logical OR operation using the two input tensors.
41  */
42 class CLLogicalOr : public IFunction
43 {
44 public:
45  /** Default Constructor */
46  CLLogicalOr();
47  /** Default Destructor */
48  ~CLLogicalOr();
49  /** Prevent instances of this class from being copied (As this class contains pointers) */
50  CLLogicalOr(const CLLogicalOr &) = delete;
51  /** Default move constructor */
53  /** Prevent instances of this class from being copied (As this class contains pointers) */
54  CLLogicalOr &operator=(const CLLogicalOr &) = delete;
55  /** Default move assignment operator */
57  /** Initialize the function
58  *
59  * Valid data layouts:
60  * - All
61  *
62  * Valid data type configurations:
63  * |src0 |src1 |dst |
64  * |:--------------|:-------------|:------------|
65  * |U8 |U8 |U8 |
66  *
67  * @param[in] input1 Input tensor. Data types supported: U8.
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.
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.
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.
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.
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.
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 };
97 
98 namespace experimental
99 {
100 class CLLogicalOr : public ICLOperator
101 {
102 public:
103  /** Default Constructor */
104  CLLogicalOr() = 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
128 } // namespace arm_compute
129 #endif /* ARM_COMPUTE_CLLOGICALOR_H */
CLLogicalOr & operator=(const CLLogicalOr &)=delete
Prevent instances of this class from being copied (As this class contains pointers) ...
Base class for all functions.
Definition: IFunction.h:30
void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output)
Initialize the function.
Definition: CLLogicalOr.cpp:71
Store the tensor&#39;s metadata.
Definition: ITensorInfo.h:43
Status class.
Definition: Error.h:52
static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output)
Static function to check if given info will lead to a valid configuration.
Definition: CLLogicalOr.cpp:85
Copyright (c) 2017-2023 Arm Limited.
~CLLogicalOr()
Default Destructor.
CLLogicalOr()
Default Constructor.
Definition: CLLogicalOr.cpp:63
CLCompileContext class.
Interface for OpenCL tensor.
Definition: ICLTensor.h:42
Basic function to run arm_compute::opencl::kernels::ClLogicalBinaryKernel.
Definition: CLLogicalOr.h:42
Tensor packing service.
Definition: ITensorPack.h:39
void run() override
Run the kernels contained in the function.
Definition: CLLogicalOr.cpp:90
Basic interface for functions which have a single async CL kernel.
Definition: ICLOperator.h:41