blob: 174f9670b399460c33e55c56c792320b0330d8b1 [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 */
51class ClTemplateCast;
Adnan AlSinan66f3d382023-07-10 15:07:45 +010052class GpuCkwCast;
Gunes Bayir1dc6ff12022-12-06 20:48:31 +000053
54class ClComponentCast final : public IGpuKernelComponent
55{
56public:
57 /** Attributes are a set of backend-agnostic parameters that define what a component does */
58 using Attributes = CastAttributes;
59 /** Settings are a set of backend-specific parameters that influence the implementation of a component */
60 using Settings = ClComponentCastSettings;
61
62 /** Validate the component
63 *
64 * @param[in] properties Component properties @ref Properties
65 * @param[in,out] tensors Tensor arguments to the component
66 * @param[in] attributes Component attributes @ref Attributes
67 * @param[in] settings Component settings @ref Settings
68 *
69 * @return Status Validation results
70 *
71 * Tensor argument names:
72 * - ACL_SRC_0: Input
73 * - ACL_DST_0: Output
74 *
75 * Tensor argument constness:
76 * - ACL_SRC_0: Const
77 * - ACL_DST_0: Const
78 *
79 * Valid data layouts:
80 * - All
81 *
82 ** Valid data type configurations:
83 * |ACL_SRC_0 |ACL_DST_0 |
84 * |:--------------|:--------------------------------------|
85 * |U8 | S8, U16, S16, U32, S32, F16, F32 |
86 * |U16 | U8, S8, S16, U32, S32, F16, F32 |
87 * |S16 | U8, S8, U16, U32, S32, F16, F32 |
88 * |U32 | U8, S8, U16, S16, S32, F16, F32 |
89 * |S32 | U8, S8, U16, S16, U32, F16, F32 |
90 * |F16 | U8, S8, U16, S16, U32, S32, F32 |
91 * |F32 | U8, S8, U16, S16, U32, S32, F16 |
92 */
93 static Status validate(
94 const Properties &properties,
95 const ArgumentPack<ITensorInfo> &tensors,
96 const Attributes &attributes,
97 const Settings &settings);
98
99 /** Constructor
100 *
101 * Similar to @ref ClComponentCast::validate()
102 */
103 ClComponentCast(ComponentId id,
104 const Properties &properties,
105 const ArgumentPack<ITensorInfo> &tensors,
106 const Attributes &attributes,
107 const Settings &settings);
108
109 /** Destructor */
110 ~ClComponentCast() override;
111 /** Prevent instances of this class from being copy constructed */
112 ClComponentCast(const ClComponentCast &component) = delete;
113 /** Prevent instances of this class from being copied */
114 ClComponentCast &operator=(const ClComponentCast &component) = delete;
115 /** Allow instances of this class to be move constructed */
116 ClComponentCast(ClComponentCast &&component) = default;
117 /** Allow instances of this class to be moved */
118 ClComponentCast &operator=(ClComponentCast &&component) = default;
119 /** Get template writer for the component */
120 const IGpuTemplateComponentWriter *template_writer() const override;
Adnan AlSinan66f3d382023-07-10 15:07:45 +0100121 /** Get GPU kernel writer for the component */
122 const IGpuCkwComponentDriver *ckw_component_driver() const override;
Gunes Bayir1dc6ff12022-12-06 20:48:31 +0000123 /** Get component type */
124 GpuComponentType type() const override
125 {
Viet-Hoa Do3558c582022-12-16 14:45:57 +0000126 return GpuComponentType::Simple;
Gunes Bayir1dc6ff12022-12-06 20:48:31 +0000127 }
128
129private:
130 std::unique_ptr<ClTemplateCast> _component_writer;
Adnan AlSinan66f3d382023-07-10 15:07:45 +0100131 std::unique_ptr<GpuCkwCast> _ckw_driver;
Gunes Bayir1dc6ff12022-12-06 20:48:31 +0000132};
133} // namespace dynamic_fusion
134} // namespace experimental
135} // namespace arm_compute
136
137#endif /* SRC_DYNAMIC_FUSION_SKETCH_GPU_COMPONENTS_CL_CLCOMPONENTCAST */