blob: 991c0eca448cec1cecd66ebd89cd78779a78163d [file] [log] [blame]
Ramy Elgammal404462a2022-11-08 02:14:46 +00001/*
SiCong Li5a63d1e2023-01-06 16:28:57 +00002 * Copyright (c) 2022-2023 Arm Limited.
Ramy Elgammal404462a2022-11-08 02:14:46 +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_TEMPLATE_WRITER_CL_CLTEMPLATEELEMENTWISEBINARY
25#define SRC_DYNAMIC_FUSION_SKETCH_GPU_TEMPLATE_WRITER_CL_CLTEMPLATEELEMENTWISEBINARY
26
27#include "arm_compute/core/experimental/Types.h"
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010028
Ramy Elgammal404462a2022-11-08 02:14:46 +000029#include "src/dynamic_fusion/sketch/gpu/components/cl/ClComponentElementwiseBinary.h"
30#include "src/dynamic_fusion/sketch/gpu/template_writer/GpuKernelVariableTable.h"
31#include "src/dynamic_fusion/sketch/gpu/template_writer/IGpuTemplateComponentWriter.h"
32
33namespace arm_compute
34{
35namespace experimental
36{
37namespace dynamic_fusion
38{
39class ClTemplateElementwiseBinary final : public IGpuTemplateComponentWriter
40{
41public:
42 using Attributes = ClComponentElementwiseBinary::Attributes;
43
44 /** Constructor
45 *
46 * Similar to @ref ClComponentElementwiseBinary::validate()
47 *
48 * @param[in] id Component id
49 * @param[in] tensors Tensor arguments to the components
50 * @param[in] attributes Component attributes
51 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010052 ClTemplateElementwiseBinary(ComponentId id, const ArgumentPack<ITensorInfo> &tensors, const Attributes &attributes);
Ramy Elgammal404462a2022-11-08 02:14:46 +000053 /** Prevent instances of this class from being copy constructed */
54 ClTemplateElementwiseBinary(const ClTemplateElementwiseBinary &elementwise) = delete;
55 /** Prevent instances of this class from being copied */
56 ClTemplateElementwiseBinary &operator=(const ClTemplateElementwiseBinary &elementwise) = delete;
57 /** Allow instances of this class to be move constructed */
58 ClTemplateElementwiseBinary(ClTemplateElementwiseBinary &&elementwise) = default;
59 /** Allow instances of this class to be moved */
60 ClTemplateElementwiseBinary &operator=(ClTemplateElementwiseBinary &&elementwise) = default;
61
62 /** Generate kernel component name */
63 std::string get_name() const override;
64
65 /** Generate kernel component code template
66 *
67 * @param[in] comp_group Component group of which the component is a part of
68 *
69 * @return std::string Component code
70 */
71 std::string get_component_code(const ComponentGroup &comp_group) const override;
72
73 /** Declare all variables used by the component in the @p vtable
74 *
75 * @param[out] vtable Variable table
76 * @param[in] comp_group Component group of which the component is a part of
77 */
78 void declare_variables(GpuKernelVariableTable &vtable, const ComponentGroup &comp_group) const override;
79
80 /** Generate the tag look-up table used to instantiate the component code.
81 *
82 * @param[in] vtable Variable table
83 * @param[in] comp_group Component group of which the component is a part of
84 *
85 * @return TagLUT Tag lookup table
86 */
87 TagLUT get_tag_lut(const GpuKernelVariableTable &vtable, const ComponentGroup &comp_group) const override;
88
89 /** Generate the build options used in the component
90 *
91 * @param[in] comp_group Component group of which the component is a part of
92 *
93 * @return CLBuildOptions Build options
94 */
95 CLBuildOptions get_build_options(const ComponentGroup &comp_group) const override;
96
97 /** Generate the component config id string used for tuning */
98 std::string get_config_id() const override;
99
100 /** Generate the header list used in the component */
101 std::set<std::string> get_headers_list() const override;
102
103 /** Generate the execution window for the component */
104 Window get_window() const override;
105
106private:
107 const ITensorInfo *_lhs;
108 const ITensorInfo *_rhs;
109 const ITensorInfo *_dst;
110 Attributes _attributes;
111};
112} // namespace dynamic_fusion
113} // namespace experimental
114} // namespace arm_compute
115#endif /* SRC_DYNAMIC_FUSION_SKETCH_GPU_TEMPLATE_WRITER_CL_CLTEMPLATEELEMENTWISEBINARY */