blob: d33e601f181f22820f9f15485639cf6ca91d92a5 [file] [log] [blame]
Mohammed Suhail Munshia18d85c2023-01-03 10:16:16 +00001/*
Gunes Bayir0ee13af2024-02-07 15:34:45 +00002 * Copyright (c) 2023-2024 Arm Limited.
Mohammed Suhail Munshia18d85c2023-01-03 10:16:16 +00003 *
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 */
Adnan AlSinan2e6d6592023-08-21 13:54:27 +010024#ifndef ACL_SRC_DYNAMIC_FUSION_SKETCH_GPU_COMPONENTS_CL_CLCOMPONENTPOOL2D_H
25#define ACL_SRC_DYNAMIC_FUSION_SKETCH_GPU_COMPONENTS_CL_CLCOMPONENTPOOL2D_H
Mohammed Suhail Munshia18d85c2023-01-03 10:16:16 +000026
27#include "arm_compute/dynamic_fusion/sketch/gpu/operators/GpuPool2d.h"
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010028
Mohammed Suhail Munshia18d85c2023-01-03 10:16:16 +000029#include "src/dynamic_fusion/sketch/gpu/components/IGpuKernelComponent.h"
30
31namespace arm_compute
32{
33/** Forward declaration */
34class ITensorInfo;
35namespace experimental
36{
37namespace dynamic_fusion
38{
39/** Forward declaration */
40template <typename T>
41class ArgumentPack;
42class Pool2dAttributes;
43
44/** Forward declaration */
Adnan AlSinan2e6d6592023-08-21 13:54:27 +010045class GpuCkwPool2d;
Mohammed Suhail Munshia18d85c2023-01-03 10:16:16 +000046
47class ClComponentPool2d final : public IGpuKernelComponent
48{
49public:
50 /** Attributes are a set of backend-agnostic parameters that define what a component does */
51 using Attributes = Pool2dAttributes;
52 /** Settings are a set of backend-specific parameters that influence the implementation of a component */
53 using Settings = GpuPool2dSettings;
54
55public:
56 /** Validate the component
57 *
58 * @param[in] properties Component properties
59 * @param[in,out] tensors Tensor arguments to the component
60 * @param[in] attributes Component attributes
61 * @param[in] settings Component settings
62 *
63 * @return Status Validation results
64 *
65 * Tensor argument names:
66 * - ACL_SRC_0: Input
67 * - ACL_DST_0: Output
68 *
69 * Tensor argument constness:
70 * - ACL_SRC_0: Const
71 * - ACL_DST_0: Const
72 *
73 * Valid data layouts:
74 * - NHWC
75 *
76 * Valid data type configurations:
77 * |ACL_SRC_0 |ACL_DST_0 |
78 * |:--------------|:--------------|
79 * |F16 |F16 |
80 * |F32 |F32 |
81 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010082 static Status validate(const Properties &properties,
83 const ArgumentPack<ITensorInfo> &tensors,
84 const Attributes &attributes,
85 const Settings &settings);
Mohammed Suhail Munshia18d85c2023-01-03 10:16:16 +000086
87 /** Constructor
88 *
89 * @param[in] id Unique Component Identifier within a workload
90 * @param[in] properties Component properties
91 * @param[in,out] tensors Tensor arguments to the component
92 * @param[in] attributes Component attributes
93 * @param[in] settings Component settings
94 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010095 ClComponentPool2d(ComponentId id,
96 const Properties &properties,
97 const ArgumentPack<ITensorInfo> &tensors,
98 const Attributes &attributes,
99 const Settings &settings);
Mohammed Suhail Munshia18d85c2023-01-03 10:16:16 +0000100
101 /** Destructor */
102 ~ClComponentPool2d() override;
103
104 /** Prevent instances of this class from being copy constructed */
105 ClComponentPool2d(const ClComponentPool2d &component) = delete;
106
107 /** Prevent instances of this class from being copied */
108 ClComponentPool2d &operator=(const ClComponentPool2d &component) = delete;
109
110 /** Allow instances of this class to be move constructed */
111 ClComponentPool2d(ClComponentPool2d &&component) = default;
112
113 /** Allow instances of this class to be moved */
114 ClComponentPool2d &operator=(ClComponentPool2d &&component) = default;
Gunes Bayir0ee13af2024-02-07 15:34:45 +0000115
Adnan AlSinan2e6d6592023-08-21 13:54:27 +0100116 /** Get GPU kernel writer for the component */
117 const IGpuCkwComponentDriver *ckw_component_driver() const override;
Mohammed Suhail Munshia18d85c2023-01-03 10:16:16 +0000118
119 /** Get component type */
120 GpuComponentType type() const override
121 {
Adnan AlSinan2e6d6592023-08-21 13:54:27 +0100122 return GpuComponentType::Complex;
Mohammed Suhail Munshia18d85c2023-01-03 10:16:16 +0000123 }
124
125private:
Adnan AlSinan2e6d6592023-08-21 13:54:27 +0100126 std::unique_ptr<GpuCkwPool2d> _component_writer;
Mohammed Suhail Munshia18d85c2023-01-03 10:16:16 +0000127};
128} // namespace dynamic_fusion
129} // namespace experimental
130} // namespace arm_compute
Adnan AlSinan2e6d6592023-08-21 13:54:27 +0100131#endif // ACL_SRC_DYNAMIC_FUSION_SKETCH_GPU_COMPONENTS_CL_CLCOMPONENTPOOL2D_H