Gunes Bayir | 1dc6ff1 | 2022-12-06 20:48:31 +0000 | [diff] [blame] | 1 | /* |
Adnan AlSinan | 66f3d38 | 2023-07-10 15:07:45 +0100 | [diff] [blame] | 2 | * Copyright (c) 2022-2023 Arm Limited. |
Gunes Bayir | 1dc6ff1 | 2022-12-06 20:48:31 +0000 | [diff] [blame] | 3 | * |
| 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 | |
| 30 | namespace arm_compute |
| 31 | { |
| 32 | /** Forward declaration */ |
| 33 | class ITensorInfo; |
| 34 | namespace experimental |
| 35 | { |
| 36 | namespace dynamic_fusion |
| 37 | { |
| 38 | /** Forward declaration */ |
| 39 | template <typename T> |
| 40 | class ArgumentPack; |
| 41 | |
| 42 | /** Component specific settings |
| 43 | */ |
| 44 | class ClComponentCastSettings |
| 45 | { |
| 46 | public: |
| 47 | private: |
| 48 | }; |
| 49 | |
| 50 | /** Forward declaration */ |
SiCong Li | 23882a9 | 2023-06-28 09:49:45 +0100 | [diff] [blame^] | 51 | #ifndef ACL_INTERNAL_TEST_CKW_IN_DF |
Gunes Bayir | 1dc6ff1 | 2022-12-06 20:48:31 +0000 | [diff] [blame] | 52 | class ClTemplateCast; |
SiCong Li | 23882a9 | 2023-06-28 09:49:45 +0100 | [diff] [blame^] | 53 | #else //ACL_INTERNAL_TEST_CKW_IN_DF |
Adnan AlSinan | 66f3d38 | 2023-07-10 15:07:45 +0100 | [diff] [blame] | 54 | class GpuCkwCast; |
SiCong Li | 23882a9 | 2023-06-28 09:49:45 +0100 | [diff] [blame^] | 55 | #endif //ACL_INTERNAL_TEST_CKW_IN_DF |
Gunes Bayir | 1dc6ff1 | 2022-12-06 20:48:31 +0000 | [diff] [blame] | 56 | |
| 57 | class ClComponentCast final : public IGpuKernelComponent |
| 58 | { |
| 59 | public: |
| 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 Li | 23882a9 | 2023-06-28 09:49:45 +0100 | [diff] [blame^] | 122 | /** Get writer for the component */ |
| 123 | #ifndef ACL_INTERNAL_TEST_CKW_IN_DF |
Gunes Bayir | 1dc6ff1 | 2022-12-06 20:48:31 +0000 | [diff] [blame] | 124 | const IGpuTemplateComponentWriter *template_writer() const override; |
SiCong Li | 23882a9 | 2023-06-28 09:49:45 +0100 | [diff] [blame^] | 125 | #else //ACL_INTERNAL_TEST_CKW_IN_DF |
Adnan AlSinan | 66f3d38 | 2023-07-10 15:07:45 +0100 | [diff] [blame] | 126 | const IGpuCkwComponentDriver *ckw_component_driver() const override; |
SiCong Li | 23882a9 | 2023-06-28 09:49:45 +0100 | [diff] [blame^] | 127 | #endif //ACL_INTERNAL_TEST_CKW_IN_DF |
Gunes Bayir | 1dc6ff1 | 2022-12-06 20:48:31 +0000 | [diff] [blame] | 128 | /** Get component type */ |
| 129 | GpuComponentType type() const override |
| 130 | { |
Viet-Hoa Do | 3558c58 | 2022-12-16 14:45:57 +0000 | [diff] [blame] | 131 | return GpuComponentType::Simple; |
Gunes Bayir | 1dc6ff1 | 2022-12-06 20:48:31 +0000 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | private: |
SiCong Li | 23882a9 | 2023-06-28 09:49:45 +0100 | [diff] [blame^] | 135 | #ifndef ACL_INTERNAL_TEST_CKW_IN_DF |
Gunes Bayir | 1dc6ff1 | 2022-12-06 20:48:31 +0000 | [diff] [blame] | 136 | std::unique_ptr<ClTemplateCast> _component_writer; |
SiCong Li | 23882a9 | 2023-06-28 09:49:45 +0100 | [diff] [blame^] | 137 | #else //ACL_INTERNAL_TEST_CKW_IN_DF |
| 138 | std::unique_ptr<GpuCkwCast> _component_writer; |
| 139 | #endif //ACL_INTERNAL_TEST_CKW_IN_DF |
Gunes Bayir | 1dc6ff1 | 2022-12-06 20:48:31 +0000 | [diff] [blame] | 140 | }; |
| 141 | } // namespace dynamic_fusion |
| 142 | } // namespace experimental |
| 143 | } // namespace arm_compute |
| 144 | |
| 145 | #endif /* SRC_DYNAMIC_FUSION_SKETCH_GPU_COMPONENTS_CL_CLCOMPONENTCAST */ |