blob: 37b8cbb6c91698e749f570d5718b27c397ae8397 [file] [log] [blame]
Gunes Bayir1dc6ff12022-12-06 20:48:31 +00001/*
Adnan AlSinan66f3d382023-07-10 15:07:45 +01002 * Copyright (c) 2022-2023 Arm Limited.
Gunes Bayir1dc6ff12022-12-06 20:48:31 +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 */
24#ifndef SRC_DYNAMIC_FUSION_SKETCH_GPU_COMPONENTS_CL_CLCOMPONENTCAST
25#define SRC_DYNAMIC_FUSION_SKETCH_GPU_COMPONENTS_CL_CLCOMPONENTCAST
26
27#include "arm_compute/dynamic_fusion/sketch/attributes/CastAttributes.h"
28#include "src/dynamic_fusion/sketch/gpu/components/IGpuKernelComponent.h"
29
30namespace arm_compute
31{
32/** Forward declaration */
33class ITensorInfo;
34namespace experimental
35{
36namespace dynamic_fusion
37{
38/** Forward declaration */
39template <typename T>
40class ArgumentPack;
41
42/** Component specific settings
43 */
44class ClComponentCastSettings
45{
46public:
47private:
48};
49
50/** Forward declaration */
SiCong Li23882a92023-06-28 09:49:45 +010051#ifndef ACL_INTERNAL_TEST_CKW_IN_DF
Gunes Bayir1dc6ff12022-12-06 20:48:31 +000052class ClTemplateCast;
SiCong Li23882a92023-06-28 09:49:45 +010053#else //ACL_INTERNAL_TEST_CKW_IN_DF
Adnan AlSinan66f3d382023-07-10 15:07:45 +010054class GpuCkwCast;
SiCong Li23882a92023-06-28 09:49:45 +010055#endif //ACL_INTERNAL_TEST_CKW_IN_DF
Gunes Bayir1dc6ff12022-12-06 20:48:31 +000056
57class ClComponentCast final : public IGpuKernelComponent
58{
59public:
60 /** Attributes are a set of backend-agnostic parameters that define what a component does */
61 using Attributes = CastAttributes;
62 /** Settings are a set of backend-specific parameters that influence the implementation of a component */
63 using Settings = ClComponentCastSettings;
64
65 /** Validate the component
66 *
67 * @param[in] properties Component properties @ref Properties
68 * @param[in,out] tensors Tensor arguments to the component
69 * @param[in] attributes Component attributes @ref Attributes
70 * @param[in] settings Component settings @ref Settings
71 *
72 * @return Status Validation results
73 *
74 * Tensor argument names:
75 * - ACL_SRC_0: Input
76 * - ACL_DST_0: Output
77 *
78 * Tensor argument constness:
79 * - ACL_SRC_0: Const
80 * - ACL_DST_0: Const
81 *
82 * Valid data layouts:
83 * - All
84 *
85 ** Valid data type configurations:
86 * |ACL_SRC_0 |ACL_DST_0 |
87 * |:--------------|:--------------------------------------|
88 * |U8 | S8, U16, S16, U32, S32, F16, F32 |
89 * |U16 | U8, S8, S16, U32, S32, F16, F32 |
90 * |S16 | U8, S8, U16, U32, S32, F16, F32 |
91 * |U32 | U8, S8, U16, S16, S32, F16, F32 |
92 * |S32 | U8, S8, U16, S16, U32, F16, F32 |
93 * |F16 | U8, S8, U16, S16, U32, S32, F32 |
94 * |F32 | U8, S8, U16, S16, U32, S32, F16 |
95 */
96 static Status validate(
97 const Properties &properties,
98 const ArgumentPack<ITensorInfo> &tensors,
99 const Attributes &attributes,
100 const Settings &settings);
101
102 /** Constructor
103 *
104 * Similar to @ref ClComponentCast::validate()
105 */
106 ClComponentCast(ComponentId id,
107 const Properties &properties,
108 const ArgumentPack<ITensorInfo> &tensors,
109 const Attributes &attributes,
110 const Settings &settings);
111
112 /** Destructor */
113 ~ClComponentCast() override;
114 /** Prevent instances of this class from being copy constructed */
115 ClComponentCast(const ClComponentCast &component) = delete;
116 /** Prevent instances of this class from being copied */
117 ClComponentCast &operator=(const ClComponentCast &component) = delete;
118 /** Allow instances of this class to be move constructed */
119 ClComponentCast(ClComponentCast &&component) = default;
120 /** Allow instances of this class to be moved */
121 ClComponentCast &operator=(ClComponentCast &&component) = default;
SiCong Li23882a92023-06-28 09:49:45 +0100122 /** Get writer for the component */
123#ifndef ACL_INTERNAL_TEST_CKW_IN_DF
Gunes Bayir1dc6ff12022-12-06 20:48:31 +0000124 const IGpuTemplateComponentWriter *template_writer() const override;
SiCong Li23882a92023-06-28 09:49:45 +0100125#else //ACL_INTERNAL_TEST_CKW_IN_DF
Adnan AlSinan66f3d382023-07-10 15:07:45 +0100126 const IGpuCkwComponentDriver *ckw_component_driver() const override;
SiCong Li23882a92023-06-28 09:49:45 +0100127#endif //ACL_INTERNAL_TEST_CKW_IN_DF
Gunes Bayir1dc6ff12022-12-06 20:48:31 +0000128 /** Get component type */
129 GpuComponentType type() const override
130 {
Viet-Hoa Do3558c582022-12-16 14:45:57 +0000131 return GpuComponentType::Simple;
Gunes Bayir1dc6ff12022-12-06 20:48:31 +0000132 }
133
134private:
SiCong Li23882a92023-06-28 09:49:45 +0100135#ifndef ACL_INTERNAL_TEST_CKW_IN_DF
Gunes Bayir1dc6ff12022-12-06 20:48:31 +0000136 std::unique_ptr<ClTemplateCast> _component_writer;
SiCong Li23882a92023-06-28 09:49:45 +0100137#else //ACL_INTERNAL_TEST_CKW_IN_DF
138 std::unique_ptr<GpuCkwCast> _component_writer;
139#endif //ACL_INTERNAL_TEST_CKW_IN_DF
Gunes Bayir1dc6ff12022-12-06 20:48:31 +0000140};
141} // namespace dynamic_fusion
142} // namespace experimental
143} // namespace arm_compute
144
145#endif /* SRC_DYNAMIC_FUSION_SKETCH_GPU_COMPONENTS_CL_CLCOMPONENTCAST */