Compute Library
 22.08
NELogical.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_NELOGICAL_H
25 #define ARM_COMPUTE_NELOGICAL_H
26 
27 #include "arm_compute/core/Error.h"
29 
30 #include <memory>
31 
32 namespace arm_compute
33 {
34 // Forward declarations
35 class ITensor;
36 class ITensorInfo;
37 
38 /** Basic function to perform logical AND */
39 class NELogicalAnd : public IFunction
40 {
41 public:
42  /** Constructor */
43  NELogicalAnd();
44  /** Prevent instances of this class from being copied (As this class contains pointers) */
45  NELogicalAnd(const NELogicalAnd &) = delete;
46  /** Prevent instances of this class from being moved (As this class contains non movable objects) */
47  NELogicalAnd(NELogicalAnd &&) = delete;
48  /** Prevent instances of this class from being copied (As this class contains pointers) */
49  NELogicalAnd &operator=(const NELogicalAnd &) = delete;
50  /** Prevent instances of this class from being moved (As this class contains non movable objects) */
51  NELogicalAnd &operator=(NELogicalAnd &&) = delete;
52  /** Destructor */
53  ~NELogicalAnd();
54 
55  /** Initialise the kernel's inputs and output
56  *
57  * Valid data layouts:
58  * - All
59  *
60  * Valid data type configurations:
61  * |src0 |src1 |dst |
62  * |:--------------|:-------------|:------------|
63  * |U8 |U8 |U8 |
64  *
65  * @param[in] input1 First tensor input. Data type supported: U8.
66  * @param[in] input2 Second tensor input. Data type supported: U8.
67  * @param[out] output Output tensor. Data type supported: U8.
68  */
69  void configure(const ITensor *input1, const ITensor *input2, ITensor *output);
70  /** Static function to check if given info will lead to a valid configuration of @ref NELogicalAnd
71  *
72  * @param[in] input1 First input tensor info. Data types supported: U8.
73  * @param[in] input2 Second input tensor info. Data types supported: U8.
74  * @param[in] output Output tensor info. Data type supported: U8
75  *
76  * @return a status
77  */
78  static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output);
79 
80  // Inherited methods overridden
81  void run() override;
82 
83 private:
84  struct Impl;
85  std::unique_ptr<Impl> _impl;
86 };
87 
88 /** Basic function to perform logical OR */
89 class NELogicalOr : public IFunction
90 {
91 public:
92  /** Constructor */
93  NELogicalOr();
94  /** Prevent instances of this class from being copied (As this class contains pointers) */
95  NELogicalOr(const NELogicalOr &) = delete;
96  /** Prevent instances of this class from being moved (As this class contains non movable objects) */
97  NELogicalOr(NELogicalOr &&) = delete;
98  /** Prevent instances of this class from being copied (As this class contains pointers) */
99  NELogicalOr &operator=(const NELogicalOr &) = delete;
100  /** Prevent instances of this class from being moved (As this class contains non movable objects) */
101  NELogicalOr &operator=(NELogicalOr &&) = delete;
102  /** Destructor */
103  ~NELogicalOr();
104 
105  /** Initialise the kernel's inputs and output
106  *
107  * Valid data layouts:
108  * - All
109  *
110  * Valid data type configurations:
111  * |src0 |src1 |dst |
112  * |:--------------|:-------------|:------------|
113  * |U8 |U8 |U8 |
114  *
115  * @param[in] input1 First tensor input. Data type supported: U8.
116  * @param[in] input2 Second tensor input. Data type supported: U8.
117  * @param[out] output Output tensor. Data type supported: U8.
118  */
119  void configure(const ITensor *input1, const ITensor *input2, ITensor *output);
120  /** Static function to check if given info will lead to a valid configuration of @ref NELogicalOr
121  *
122  * @param[in] input1 First input tensor info. Data types supported: U8.
123  * @param[in] input2 Second input tensor info. Data types supported: U8.
124  * @param[in] output Output tensor info. Data type supported: U8
125  *
126  * @return a status
127  */
128  static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output);
129 
130  // Inherited methods overridden
131  void run() override;
132 
133 private:
134  struct Impl;
135  std::unique_ptr<Impl> _impl;
136 };
137 
138 /** Basic function to perform logical NOT */
139 class NELogicalNot : public IFunction
140 {
141 public:
142  /** Constructor */
143  NELogicalNot();
144  /** Prevent instances of this class from being copied (As this class contains pointers) */
145  NELogicalNot(const NELogicalNot &) = delete;
146  /** Prevent instances of this class from being moved (As this class contains non movable objects) */
147  NELogicalNot(NELogicalNot &&) = delete;
148  /** Prevent instances of this class from being copied (As this class contains pointers) */
149  NELogicalNot &operator=(const NELogicalNot &) = delete;
150  /** Prevent instances of this class from being moved (As this class contains non movable objects) */
151  NELogicalNot &operator=(NELogicalNot &&) = delete;
152  /** Destructor */
153  ~NELogicalNot();
154 
155  /** Initialise the kernel's inputs and output
156  *
157  * Valid data layouts:
158  * - All
159  *
160  * Valid data type configurations:
161  * |src |dst |
162  * |:--------------|:-------------|
163  * |U8 |U8 |
164  *
165  * @param[in] input Input tensor. Data type supported: U8.
166  * @param[out] output Output tensor. Data type supported: U8.
167  */
168  void configure(const ITensor *input, ITensor *output);
169  /** Static function to check if given info will lead to a valid configuration of @ref NELogicalNot
170  *
171  * @param[in] input Input tensor info. Data types supported: U8.
172  * @param[in] output Output tensor info. Data type supported: U8
173  *
174  * @return a status
175  */
176  static Status validate(const ITensorInfo *input, const ITensorInfo *output);
177 
178  // Inherited methods overridden
179  void run() override;
180 
181 private:
182  struct Impl;
183  std::unique_ptr<Impl> _impl;
184 };
185 } // namespace arm_compute
186 #endif /* ARM_COMPUTE_NELOGICAL_H */
Base class for all functions.
Definition: IFunction.h:30
~NELogicalAnd()
Destructor.
Basic function to perform logical NOT.
Definition: NELogical.h:139
Basic function to perform logical OR.
Definition: NELogical.h:89
Store the tensor&#39;s metadata.
Definition: ITensorInfo.h:40
Status class.
Definition: Error.h:52
Interface for CPU tensor.
Definition: ITensor.h:36
Copyright (c) 2017-2022 Arm Limited.
void configure(const ITensor *input1, const ITensor *input2, ITensor *output)
Initialise the kernel&#39;s inputs and output.
Definition: NELogical.cpp:48
NELogicalAnd & operator=(const NELogicalAnd &)=delete
Prevent instances of this class from being copied (As this class contains pointers) ...
Basic function to perform logical AND.
Definition: NELogical.h:39
void run() override
Run the kernels contained in the function.
Definition: NELogical.cpp:67
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 of NELogicalAnd.
Definition: NELogical.cpp:62
NELogicalAnd()
Constructor.
Definition: NELogical.cpp:42