blob: af766a7eceb7eb6850015e7525c869c45b376a69 [file] [log] [blame]
SiCong Lif44bbc52022-08-29 18:25:51 +01001/*
SiCong Li19844f62023-05-16 16:46:34 +01002 * Copyright (c) 2022-2023 Arm Limited.
SiCong Lif44bbc52022-08-29 18:25:51 +01003 *
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 */
SiCong Li19844f62023-05-16 16:46:34 +010024#ifndef ACL_SRC_DYNAMIC_FUSION_SKETCH_GPU_COMPONENTS_IGPUKERNELCOMPONENT
25#define ACL_SRC_DYNAMIC_FUSION_SKETCH_GPU_COMPONENTS_IGPUKERNELCOMPONENT
SiCong Lif44bbc52022-08-29 18:25:51 +010026
27#include "Types.h"
28
29#include "src/dynamic_fusion/sketch/ArgumentPack.h"
30#include "src/dynamic_fusion/sketch/gpu/GpuWorkloadSourceCode.h"
31
32namespace arm_compute
33{
34namespace experimental
35{
36namespace dynamic_fusion
37{
38/** Properties common to all kernel component types */
39class KernelProperties
40{
41public:
42 KernelProperties &stage(const UnitWorkloadStage &stage)
43 {
44 _stage = stage;
45 return *this;
46 }
47 UnitWorkloadStage stage() const
48 {
49 return _stage;
50 }
51
52private:
53 UnitWorkloadStage _stage{};
54};
55
56inline bool operator==(const KernelProperties &config0, const KernelProperties &config1)
57{
58 return config0.stage() == config1.stage();
59}
60
61/** Forward declaration */
62class IGpuTemplateComponentWriter;
SiCong Li19844f62023-05-16 16:46:34 +010063class IGpuCkwComponentDriver;
SiCong Lif44bbc52022-08-29 18:25:51 +010064
65/** An abstract interface of a component. It enables manipulation by the component graph for purposes like fusion
66 */
67class IGpuKernelComponent
68{
69public:
70 using Properties = KernelProperties;
71
72public:
73 /** Constructor
74 *
75 * @param[in] id Component id
76 * @param[in] properties Kernel component properties
77 * @param[in] tensors Tensor arguments to the components
78 */
79 IGpuKernelComponent(
80 ComponentId id,
81 const Properties &properties,
82 const ArgumentPack<ITensorInfo> &tensors)
83 : _id{ id },
84 _properties{ properties },
85 _tensors{ tensors }
86 {
87 }
88 /** Destructor */
89 virtual ~IGpuKernelComponent()
90 {
91 }
92 /** Get component id */
93 ComponentId id() const
94 {
95 return _id;
96 }
97 /** Get tensor arguments */
98 ArgumentPack<ITensorInfo> tensors() const
99 {
100 return _tensors;
101 }
102 /** Get properties */
103 Properties properties() const
104 {
105 return _properties;
106 }
SiCong Li23882a92023-06-28 09:49:45 +0100107 /** Get writer for the component */
108 virtual const IGpuTemplateComponentWriter *template_writer() const
109 {
110 return nullptr;
111 }
SiCong Li19844f62023-05-16 16:46:34 +0100112 virtual const IGpuCkwComponentDriver *ckw_component_driver() const
113 {
114 return nullptr;
115 }
SiCong Lif44bbc52022-08-29 18:25:51 +0100116 /** Get component type */
117 virtual GpuComponentType type() const = 0;
118
119private:
120 ComponentId _id{ -1 };
121 Properties _properties{};
122 ArgumentPack<ITensorInfo> _tensors{};
123};
124} // namespace dynamic_fusion
125} // namespace experimental
126} // namespace arm_compute
SiCong Li19844f62023-05-16 16:46:34 +0100127#endif /* ACL_SRC_DYNAMIC_FUSION_SKETCH_GPU_COMPONENTS_IGPUKERNELCOMPONENT */