blob: ed77b1203b68755fc0f663adf119c1f281048c20 [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"
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010028
Gunes Bayir1dc6ff12022-12-06 20:48:31 +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;
42
43/** Component specific settings
44 */
45class ClComponentCastSettings
46{
47public:
48private:
49};
50
51/** Forward declaration */
SiCong Li23882a92023-06-28 09:49:45 +010052#ifndef ACL_INTERNAL_TEST_CKW_IN_DF
Gunes Bayir1dc6ff12022-12-06 20:48:31 +000053class ClTemplateCast;
SiCong Li23882a92023-06-28 09:49:45 +010054#else //ACL_INTERNAL_TEST_CKW_IN_DF
Adnan AlSinan66f3d382023-07-10 15:07:45 +010055class GpuCkwCast;
SiCong Li23882a92023-06-28 09:49:45 +010056#endif //ACL_INTERNAL_TEST_CKW_IN_DF
Gunes Bayir1dc6ff12022-12-06 20:48:31 +000057
58class ClComponentCast final : public IGpuKernelComponent
59{
60public:
61 /** Attributes are a set of backend-agnostic parameters that define what a component does */
62 using Attributes = CastAttributes;
63 /** Settings are a set of backend-specific parameters that influence the implementation of a component */
64 using Settings = ClComponentCastSettings;
65
66 /** Validate the component
67 *
68 * @param[in] properties Component properties @ref Properties
69 * @param[in,out] tensors Tensor arguments to the component
70 * @param[in] attributes Component attributes @ref Attributes
71 * @param[in] settings Component settings @ref Settings
72 *
73 * @return Status Validation results
74 *
75 * Tensor argument names:
76 * - ACL_SRC_0: Input
77 * - ACL_DST_0: Output
78 *
79 * Tensor argument constness:
80 * - ACL_SRC_0: Const
81 * - ACL_DST_0: Const
82 *
83 * Valid data layouts:
84 * - All
85 *
86 ** Valid data type configurations:
87 * |ACL_SRC_0 |ACL_DST_0 |
88 * |:--------------|:--------------------------------------|
89 * |U8 | S8, U16, S16, U32, S32, F16, F32 |
90 * |U16 | U8, S8, S16, U32, S32, F16, F32 |
91 * |S16 | U8, S8, U16, U32, S32, F16, F32 |
92 * |U32 | U8, S8, U16, S16, S32, F16, F32 |
93 * |S32 | U8, S8, U16, S16, U32, F16, F32 |
94 * |F16 | U8, S8, U16, S16, U32, S32, F32 |
95 * |F32 | U8, S8, U16, S16, U32, S32, F16 |
96 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010097 static Status validate(const Properties &properties,
98 const ArgumentPack<ITensorInfo> &tensors,
99 const Attributes &attributes,
100 const Settings &settings);
Gunes Bayir1dc6ff12022-12-06 20:48:31 +0000101
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 */