Jakub Sujak | 3274172 | 2022-11-25 16:43:18 +0000 | [diff] [blame] | 1 | /* |
SiCong Li | 9129549 | 2023-07-21 18:16:13 +0100 | [diff] [blame] | 2 | * Copyright (c) 2022-2023 Arm Limited. |
Jakub Sujak | 3274172 | 2022-11-25 16:43:18 +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_TEMPLATE_WRITER_CL_CLTEMPLATEACTIVATION |
| 25 | #define SRC_DYNAMIC_FUSION_SKETCH_GPU_TEMPLATE_WRITER_CL_CLTEMPLATEACTIVATION |
| 26 | |
| 27 | #include "arm_compute/core/experimental/Types.h" |
SiCong Li | 9129549 | 2023-07-21 18:16:13 +0100 | [diff] [blame] | 28 | #include "arm_compute/function_info/ActivationLayerInfo.h" |
Jakub Sujak | 3274172 | 2022-11-25 16:43:18 +0000 | [diff] [blame] | 29 | #include "src/dynamic_fusion/sketch/gpu/components/cl/ClComponentActivation.h" |
| 30 | #include "src/dynamic_fusion/sketch/gpu/template_writer/GpuKernelVariableTable.h" |
| 31 | #include "src/dynamic_fusion/sketch/gpu/template_writer/IGpuTemplateComponentWriter.h" |
| 32 | |
| 33 | namespace arm_compute |
| 34 | { |
| 35 | namespace experimental |
| 36 | { |
| 37 | namespace dynamic_fusion |
| 38 | { |
| 39 | class ClTemplateActivation final : public IGpuTemplateComponentWriter |
| 40 | { |
| 41 | public: |
| 42 | using Attributes = ClComponentActivation::Attributes; |
| 43 | |
| 44 | /** Constructor |
| 45 | * |
| 46 | * @param[in] id Component id |
| 47 | * @param[in] tensors Tensor arguments to the components |
| 48 | * @param[in] attributes Component attributes |
| 49 | */ |
| 50 | ClTemplateActivation(ComponentId id, const ArgumentPack<ITensorInfo> &tensors, const Attributes &attributes); |
| 51 | |
| 52 | /** Destructor */ |
| 53 | ~ClTemplateActivation() override = default; |
| 54 | |
| 55 | /** Prevent instances of this class from being copy constructed */ |
| 56 | ClTemplateActivation(const ClTemplateActivation &activation) = delete; |
| 57 | |
| 58 | /** Prevent instances of this class from being copied */ |
| 59 | ClTemplateActivation &operator=(const ClTemplateActivation &activation) = delete; |
| 60 | |
| 61 | /** Allow instances of this class to be move constructed */ |
| 62 | ClTemplateActivation(ClTemplateActivation &&activation) = default; |
| 63 | |
| 64 | /** Allow instances of this class to be moved */ |
| 65 | ClTemplateActivation &operator=(ClTemplateActivation &&activation) = default; |
| 66 | |
| 67 | /** Generate kernel component name */ |
| 68 | std::string get_name() const override; |
| 69 | |
| 70 | /** Generate kernel component code template |
| 71 | * |
| 72 | * @param[in] comp_group Component group of which the component is a part of |
| 73 | * |
| 74 | * @return std::string Component code |
| 75 | */ |
| 76 | std::string get_component_code(const ComponentGroup &comp_group) const override; |
| 77 | |
| 78 | /** Declare all variables used by the component in the @p vtable |
| 79 | * |
| 80 | * @param[out] vtable Variable table |
| 81 | * @param[in] comp_group Component group of which the component is a part of |
| 82 | */ |
| 83 | void declare_variables(GpuKernelVariableTable &vtable, const ComponentGroup &comp_group) const override; |
| 84 | |
| 85 | /** Generate the tag look-up table used to instantiate the component code. |
| 86 | * |
| 87 | * @param[in] vtable Variable table |
| 88 | * @param[in] comp_group Component group of which the component is a part of |
| 89 | * |
| 90 | * @return TagLUT Tag lookup table |
| 91 | */ |
| 92 | TagLUT get_tag_lut(const GpuKernelVariableTable &vtable, const ComponentGroup &comp_group) const override; |
| 93 | |
| 94 | /** Generate the build options used in the component |
| 95 | * |
| 96 | * @param[in] comp_group Component group of which the component is a part of |
| 97 | * |
| 98 | * @return CLBuildOptions Build options |
| 99 | */ |
| 100 | CLBuildOptions get_build_options(const ComponentGroup &comp_group) const override; |
| 101 | |
| 102 | /** Generate the component config id string used for tuning */ |
| 103 | std::string get_config_id() const override; |
| 104 | |
| 105 | /** Generate the header list used in the component */ |
| 106 | std::set<std::string> get_headers_list() const override; |
| 107 | |
| 108 | /** Generate the execution window for the component */ |
| 109 | Window get_window() const override; |
| 110 | |
| 111 | private: |
| 112 | const ITensorInfo *_src; |
| 113 | const ITensorInfo *_dst; |
| 114 | Attributes _attributes; |
| 115 | }; |
| 116 | } // namespace dynamic_fusion |
| 117 | } // namespace experimental |
| 118 | } // namespace arm_compute |
| 119 | #endif /* SRC_DYNAMIC_FUSION_SKETCH_GPU_TEMPLATE_WRITER_CL_CLTEMPLATEACTIVATION */ |