Debian Codegraph @

arm_compute/runtime/experimental/operators/CpuGemmDirectConv2d.h

raw
1 /*
2 * Copyright (c) 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_CPUGEMMDIRECTCONV2D_H
26 #define ACL_ARM_COMPUTE_RUNTIME_EXPERIMENTAL_OPERATORS_CPUGEMMDIRECTCONV2D_H
27
28 #include "arm_compute/core/ITensorPack.h"
29 #include "arm_compute/core/TensorInfo.h"
30 #include "arm_compute/runtime/FunctionDescriptors.h"
31 #include "arm_compute/runtime/IOperator.h"
32
33 namespace arm_compute
34 {
35 namespace experimental
36 {
37 namespace op
38 {
39 /*
40 * A shallow wrapper for arm_compute::cpu::CpuGemmDirectConv2d.
41 * Any new features should be added to arm_compute::cpu::CpuGemmDirectConv2d and
42 * arm_compute::experimental::op::CpuGemmDirectConv2d should remain a shallow wrapper.
43 */
44 class CpuGemmDirectConv2d : public IOperator
45 {
46 public:
47 /** Constructor **/
48 CpuGemmDirectConv2d();
49 /** Prevent instances of this class from being copied (As this class contains pointers) */
50 CpuGemmDirectConv2d(const CpuGemmDirectConv2d &) = delete;
51 /** Prevent copy assignment */
52 CpuGemmDirectConv2d &operator=(const CpuGemmDirectConv2d &) = delete;
53 /** Default move constructor */
54 CpuGemmDirectConv2d(CpuGemmDirectConv2d &&) = default;
55 /** Default move assignment */
56 CpuGemmDirectConv2d &operator=(CpuGemmDirectConv2d &&) = default;
57 /** Default destructor */
58 ~CpuGemmDirectConv2d() override;
59
60 /** Set the input and output tensors.
61 *
62 * Valid data layouts:
63 * - All
64 *
65 * Valid data type configurations:
66 * |src0 |src1 |src2 |dst |
67 * |:--------------|:--------------|:--------------|:--------------|
68 * |QASYMM8 |QASYMM8 |S32 |QASYMM8 |
69 * |QASYMM8_SIGNED |QASYMM8_SIGNED |S32 |QASYMM8_SIGNED |
70 * |F16 |F16 |F16 |F16 |
71 * |F32 |F32 |F32 |F32 |
72 * |BFLOAT16 |BFLOAT16 |BFLOAT16 |BFLOAT16 |
73 *
74 * @param[in] src Source tensor info. 3 lower dimensions represent a single input [width, height, IFM],
75 * while every optional dimension from 4 and above represent a batch of inputs.
76 * Data types supported: QASYMM8/QASYMM8_SIGNED/BFLOAT16/F16/F32.
77 * @param[in] weights Weights tensor info. Weights are 4D tensor with dimensions [kernel_x, kernel_y, IFM, OFM].
78 * Data type supported: QASYMM8/QASYMM8_SIGNED/QSYMM8_PER_CHANNEL/BFLOAT16/F16/F32.
79 * @param[in] biases Biases tensor info. Shared biases supported. Biases are 1D tensor with dimensions [OFM].
80 * Data type supported: Should match @p input data type, except for input of QASYMM8/QASYMM8_SIGNED type where biases should be of S32 type.
81 * @param[in] dst Destination tensor info. 3 lower dimensions represent a single output [width, height, OFM], while the rest represent batch of outputs.
82 * Data types supported: Same as @p input.
83 * @param[in] info Contains padding and stride information described in @ref PadStrideInfo.
84 */
85 void configure(const ITensorInfo *src,
86 const ITensorInfo *weights,
87 const ITensorInfo *biases,
88 ITensorInfo *dst,
89 const Conv2dInfo &info);
90 /** Static function to check if given info will lead to a valid configuration of @ref CpuGemmDirectConv2d
91 *
92 * Similar to CpuGemmDirectConv2d::configure()
93 *
94 * @return a status
95 */
96 static Status validate(const ITensorInfo *src,
97 const ITensorInfo *weights,
98 const ITensorInfo *biases,
99 const ITensorInfo *dst,
100 const Conv2dInfo &info);
101
102 // Inherited methods overridden:
103 void run(ITensorPack &tensors) override;
104 void prepare(ITensorPack &constants) override;
105 experimental::MemoryRequirements workspace() const override;
106
107 private:
108 struct Impl;
109 std::unique_ptr<Impl> _impl;
110 };
111 } // namespace op
112 } // namespace experimental
113 } // namespace arm_compute
114
115 #endif // ACL_ARM_COMPUTE_RUNTIME_EXPERIMENTAL_OPERATORS_CPUGEMMDIRECTCONV2D_H