blob: 5d232c0cf25d7a148630c2877285972cd76afaf0 [file] [log] [blame]
Gunes Bayiraecb5d92022-12-18 21:31:29 +00001/*
2 * Copyright (c) 2022 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
25#ifndef SRC_DYNAMIC_FUSION_SKETCH_GPU_TEMPLATE_WRITER_CL_CLTEMPLATELOGITS1DMAXSHIFTEXPSUM
26#define SRC_DYNAMIC_FUSION_SKETCH_GPU_TEMPLATE_WRITER_CL_CLTEMPLATELOGITS1DMAXSHIFTEXPSUM
27
28#include "src/dynamic_fusion/sketch/gpu/components/cl/ClComponentLogits1DMaxShiftExpSum.h"
29#include "src/dynamic_fusion/sketch/gpu/template_writer/GpuKernelVariableTable.h"
30#include "src/dynamic_fusion/sketch/gpu/template_writer/IGpuTemplateComponentWriter.h"
31
32namespace arm_compute
33{
34namespace experimental
35{
36namespace dynamic_fusion
37{
38class ClTemplateLogits1DMaxShiftExpSum final : public IGpuTemplateComponentWriter
39{
40public:
41 using Attributes = ClComponentLogits1DMaxShiftExpSum::Attributes;
42
43 /** Constructor
44 *
45 * @param[in] id Component id
46 * @param[in] tensors Tensor arguments to the components
47 * @param[in] attributes Component attributes
48 */
49 ClTemplateLogits1DMaxShiftExpSum(ComponentId id, const ArgumentPack<ITensorInfo> &tensors, const Attributes &attributes);
50 /** Prevent instances of this class from being copy constructed */
51 ClTemplateLogits1DMaxShiftExpSum(const ClTemplateLogits1DMaxShiftExpSum &) = delete;
52 /** Prevent instances of this class from being copied */
53 ClTemplateLogits1DMaxShiftExpSum &operator=(const ClTemplateLogits1DMaxShiftExpSum &) = delete;
54 /** Allow instances of this class to be move constructed */
55 ClTemplateLogits1DMaxShiftExpSum(ClTemplateLogits1DMaxShiftExpSum &&) = default;
56 /** Allow instances of this class to be moved */
57 ClTemplateLogits1DMaxShiftExpSum &operator=(ClTemplateLogits1DMaxShiftExpSum &&) = default;
58 /** Generate kernel component name */
59 std::string get_name() const override;
60 /** Generate kernel component code template
61 *
62 * @param[in] comp_group Component group of which the component is a part of
63 *
64 * @return std::string Component code
65 */
66 std::string get_component_code(const ComponentGroup &comp_group) const override;
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 /** Generate the tag look-up table used to instantiate the component code.
74 *
75 * @param[in] vtable Variable table
76 * @param[in] comp_group Component group of which the component is a part of
77 *
78 * @return TagLUT Tag lookup table
79 */
80 TagLUT get_tag_lut(const GpuKernelVariableTable &vtable, const ComponentGroup &comp_group) const override;
81 /** Generate the build options used in the component
82 *
83 * @param[in] comp_group Component group of which the component is a part of
84 *
85 * @return CLBuildOptions Build options
86 */
87 CLBuildOptions get_build_options(const ComponentGroup &comp_group) const override;
88 /** Generate the component config id string used for tuning */
89 std::string get_config_id() const override;
90 /** Generate the header list used in the component */
91 std::set<std::string> get_headers_list() const override;
92 /** Generate the execution window for the component */
93 Window get_window() const override;
94
95private:
96 const ITensorInfo *_src; // input
97 const ITensorInfo *_sum; // exponentiated and summed input
98 const ITensorInfo *_dst; // exponentiated input
99 Attributes _attributes;
100};
101} // namespace dynamic_fusion
102} // namespace experimental
103} // namespace arm_compute
104
105#endif /* SRC_DYNAMIC_FUSION_SKETCH_GPU_TEMPLATE_WRITER_CL_CLTEMPLATELOGITS1DMAXSHIFTEXPSUM */