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