xref: /aosp_15_r20/external/ComputeLibrary/src/dynamic_fusion/sketch/gpu/components/cl/ClComponentStore.h (revision c217d954acce2dbc11938adb493fc0abd69584f3)
1 /*
2  * Copyright (c) 2022 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 SRC_DYNAMIC_FUSION_SKETCH_GPU_COMPONENTS_CL_CLCOMPONENTSTORE
25 #define SRC_DYNAMIC_FUSION_SKETCH_GPU_COMPONENTS_CL_CLCOMPONENTSTORE
26 
27 #include "arm_compute/core/Error.h"
28 #include "src/dynamic_fusion/sketch/gpu/components/IGpuKernelComponent.h"
29 #include "src/dynamic_fusion/sketch/gpu/template_writer/cl/ClTemplateStore.h"
30 #include <memory>
31 
32 namespace arm_compute
33 {
34 /** Forward declaration */
35 class ITensorInfo;
36 namespace experimental
37 {
38 namespace dynamic_fusion
39 {
40 /** Forward declaration */
41 template <typename T>
42 class ArgumentPack;
43 
44 class ClComponentStore final : public IGpuKernelComponent
45 {
46 public:
47     /** Validate the component
48      *
49      * @param[in] properties Component properties
50      * @param[in] tensors    Tensor arguments to the components
51      *
52      * @return Status        Validation results
53      *
54      * Tensor argument names:
55      * - ACL_SRC_0: Input
56      * - ACL_DST_0: Output
57      *
58      * Tensor argument constness:
59      * - ACL_SRC_0: Const
60      * - ACL_DST_0: Const
61      *
62      * Valid data layouts:
63      * - NHWC
64      *
65      * Valid data type configurations:
66      * |ACL_SRC_0      |ACL_DST_0      |
67      * |:--------------|:--------------|
68      * |All            |All            |
69      */
70     static Status validate(
71         const Properties                &properties,
72         const ArgumentPack<ITensorInfo> &tensors);
73     /** Constructor
74      *
75      * Similar to @ref ClComponentStore::validate()
76      */
77     ClComponentStore(ComponentId id, const Properties &properties, const ArgumentPack<ITensorInfo> &tensors);
78     /** Destructor */
79     ~ClComponentStore() override;
80     /** Prevent instances of this class from being copy constructed */
81     ClComponentStore(const ClComponentStore &component) = delete;
82     /** Prevent instances of this class from being copied */
83     ClComponentStore &operator=(const ClComponentStore &component) = delete;
84     /** Allow instances of this class to be move constructed */
85     ClComponentStore(ClComponentStore &&component) = default;
86     /** Allow instances of this class to be moved */
87     ClComponentStore &operator=(ClComponentStore &&component) = default;
88     /** Get template writer for the component */
89     const IGpuTemplateComponentWriter *template_writer() const override;
90     /** Get component type */
type()91     GpuComponentType type() const override
92     {
93         return GpuComponentType::Output;
94     }
95 
96 private:
97     std::unique_ptr<ClTemplateStore> _component_writer;
98 };
99 } // namespace dynamic_fusion
100 } // namespace experimental
101 } // namespace arm_compute
102 #endif /* SRC_DYNAMIC_FUSION_SKETCH_GPU_COMPONENTS_CL_CLCOMPONENTSTORE */
103