Debian Codegraph @

arm_compute/runtime/experimental/operators/CpuElementwise.h

raw
1 /*
2 * Copyright (c) 2021, 2024 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
25 #ifndef ACL_ARM_COMPUTE_RUNTIME_EXPERIMENTAL_OPERATORS_CPUELEMENTWISE_H
26 #define ACL_ARM_COMPUTE_RUNTIME_EXPERIMENTAL_OPERATORS_CPUELEMENTWISE_H
27
28 #include "arm_compute/core/ITensorPack.h"
29 #include "arm_compute/core/Types.h"
30 #include "arm_compute/runtime/NEON/INEOperator.h"
31
32 #include <memory>
33
34 namespace arm_compute
35 {
36 namespace experimental
37 {
38 namespace op
39 {
40
41 /** Wrapper class for CpuElementwiseDivision. For information on the functions,
42 * see "src/cpu/operators/CpuElementwise.h"
43 */
44 class CpuElementwiseDivision : public INEOperator
45 {
46 public:
47 /** Constructor */
48 CpuElementwiseDivision();
49 /** Prevent instances of this class from being copied (As this class contains pointers) */
50 CpuElementwiseDivision(CpuElementwiseDivision &) = delete;
51 /** Prevent instances of this class from being copied (As this class contains pointers) */
52 CpuElementwiseDivision &operator=(CpuElementwiseDivision &) = delete;
53 /** Default move constructor */
54 CpuElementwiseDivision(CpuElementwiseDivision &&) = default;
55 /** Default move assignment */
56 CpuElementwiseDivision &operator=(CpuElementwiseDivision &&) = default;
57 /** Defualt destructor */
58 ~CpuElementwiseDivision() override;
59 /** Initialise the kernel's inputs, dst and conversion policy.
60 *
61 * @param[in, out] src0 First tensor input info. Data types supported: S32/F16/F32.
62 * @param[in, out] src1 Second tensor input info. Data types supported: Same as @p src0.
63 * @param[out] dst Output tensor info. Data types supported: Same as @p src0.
64 */
65 void configure(const ITensorInfo *src0, const ITensorInfo *src1, ITensorInfo *dst);
66 /** Static function to check if given info will lead to a valid configuration
67 *
68 * Similar to @ref CpuElementwiseDivision::configure()
69 *
70 * @return a status
71 */
72 static Status validate(const ITensorInfo *src0, const ITensorInfo *src1, const ITensorInfo *dst);
73
74 void run(ITensorPack &tensors) override;
75
76 private:
77 struct Impl;
78 std::unique_ptr<Impl> _impl;
79 };
80
81 /** Wrapper class for CpuElementwiseMax. For information on the functions,
82 * see "src/cpu/operators/CpuElementwise.h"
83 */
84 class CpuElementwiseMax : public INEOperator
85 {
86 public:
87 /** Constructor */
88 CpuElementwiseMax();
89 /** Prevent instances of this class from being copied (As this class contains pointers) */
90 CpuElementwiseMax(CpuElementwiseMax &) = delete;
91 /** Prevent instances of this class from being copied (As this class contains pointers) */
92 CpuElementwiseMax &operator=(CpuElementwiseMax &) = delete;
93 /** Default move constructor */
94 CpuElementwiseMax(CpuElementwiseMax &&) = default;
95 /** Default move assignment */
96 CpuElementwiseMax &operator=(CpuElementwiseMax &&) = default;
97 /** Defualt destructor */
98 ~CpuElementwiseMax() override;
99 /** Configure the operator
100 *
101 * @param[in] src0 The first source tensor information.
102 * @param[in] src1 The second source tensor information. With PRelu, this is used as alpha tensor.
103 * @param[out] dst The output tensor information.
104 */
105 void configure(const ITensorInfo *src0, const ITensorInfo *src1, ITensorInfo *dst);
106 /** Static function to check if given info will lead to a valid configuration
107 *
108 * Similar to @ref CpuElementwiseMax::configure()
109 *
110 * @return a status
111 */
112 static Status validate(const ITensorInfo *src0, const ITensorInfo *src1, const ITensorInfo *dst);
113
114 void run(ITensorPack &tensors) override;
115
116 private:
117 struct Impl;
118 std::unique_ptr<Impl> _impl;
119 };
120
121 /** Wrapper class for CpuElementwiseMin. For information on the functions,
122 * see "src/cpu/operators/CpuElementwise.h"
123 */
124 class CpuElementwiseMin : public INEOperator
125 {
126 public:
127 /** Constructor */
128 CpuElementwiseMin();
129 /** Prevent instances of this class from being copied (As this class contains pointers) */
130 CpuElementwiseMin(CpuElementwiseMin &) = delete;
131 /** Prevent instances of this class from being copied (As this class contains pointers) */
132 CpuElementwiseMin &operator=(CpuElementwiseMin &) = delete;
133 /** Default move constructor */
134 CpuElementwiseMin(CpuElementwiseMin &&) = default;
135 /** Default move assignment */
136 CpuElementwiseMin &operator=(CpuElementwiseMin &&) = default;
137 /** Defualt destructor */
138 ~CpuElementwiseMin() override;
139 /** Configure the operator
140 *
141 * @param[in] src0 The first source tensor information.
142 * @param[in] src1 The second source tensor information. With PRelu, this is used as alpha tensor.
143 * @param[out] dst The output tensor information.
144 */
145 void configure(const ITensorInfo *src0, const ITensorInfo *src1, ITensorInfo *dst);
146 /** Static function to check if given info will lead to a valid configuration
147 *
148 * Similar to @ref CpuElementwiseMin::configure()
149 *
150 * @return a status
151 */
152 static Status validate(const ITensorInfo *src0, const ITensorInfo *src1, const ITensorInfo *dst);
153
154 void run(ITensorPack &tensors) override;
155
156 private:
157 struct Impl;
158 std::unique_ptr<Impl> _impl;
159 };
160
161 } // namespace op
162 } // namespace experimental
163 } // namespace arm_compute
164 #endif // ACL_ARM_COMPUTE_RUNTIME_EXPERIMENTAL_OPERATORS_CPUELEMENTWISE_H