Debian Codegraph @

arm_compute/runtime/experimental/operators/CpuSub.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 #ifndef ACL_ARM_COMPUTE_RUNTIME_EXPERIMENTAL_OPERATORS_CPUSUB_H
25 #define ACL_ARM_COMPUTE_RUNTIME_EXPERIMENTAL_OPERATORS_CPUSUB_H
26
27 #include "arm_compute/core/ITensorInfo.h"
28 #include "arm_compute/core/ITensorPack.h"
29 #include "arm_compute/function_info/ActivationLayerInfo.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 CpuSub. For information on the functions,
42 * see "src/cpu/operators/CpuSub.h"
43 */
44 class CpuSub : public INEOperator
45 {
46 public:
47 /** Constructor */
48 CpuSub();
49 /** Prevent instances of this class from being copied (As this class contains pointers) */
50 CpuSub(const CpuSub &) = delete;
51 /** Prevent instances of this class from being copied (As this class contains pointers) */
52 CpuSub &operator=(const CpuSub &) = delete;
53 /** Default move constructor */
54 CpuSub(CpuSub &&) = default;
55 /** Default move assignment */
56 CpuSub &operator=(CpuSub &&) = default;
57 /** Default destructor */
58 ~CpuSub() override;
59 /** Initialise the kernel's inputs, dst and conversion policy.
60 *
61 * Valid configurations (src0,src1) -> dst :
62 *
63 * - (U8,U8) -> U8
64 * - (QASYMM8, QASYMM8) -> QASYMM8
65 * - (QASYMM8_SIGNED, QASYMM8_SIGNED) -> QASYMM8_SIGNED
66 * - (S16,S16) -> S16
67 * - (S32,S32) -> S32
68 * - (F16,F16) -> F16
69 * - (F32,F32) -> F32
70 *
71 * @param[in] src0 First tensor input info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/QSYMM16/S16/S32/F16/F32
72 * @param[in] src1 Second tensor input info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/QSYMM16/S16/S32/F16/F32
73 * @param[out] dst Output tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/QSYMM16/S16/S32/F16/F32
74 * @param[in] policy Policy to use to handle overflow. Convert policy cannot be WRAP if datatype is quantized.
75 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
76 */
77 void configure(const ITensorInfo *src0,
78 const ITensorInfo *src1,
79 ITensorInfo *dst,
80 ConvertPolicy policy,
81 const ActivationLayerInfo &act_info = ActivationLayerInfo());
82 /** Static function to check if given info will lead to a valid configuration
83 *
84 * Similar to @ref CpuSub::configure()
85 *
86 * @return a status
87 */
88 static Status validate(const ITensorInfo *src0,
89 const ITensorInfo *src1,
90 const ITensorInfo *dst,
91 ConvertPolicy policy,
92 const ActivationLayerInfo &act_info = ActivationLayerInfo());
93
94 void run(ITensorPack &tensors) override;
95
96 private:
97 struct Impl;
98 std::unique_ptr<Impl> _impl;
99 };
100
101 } // namespace op
102 } // namespace experimental
103 } // namespace arm_compute
104 #endif // ACL_ARM_COMPUTE_RUNTIME_EXPERIMENTAL_OPERATORS_CPUSUB_H