blob: 84b689ef643bb13928ccc9ae872daec6aee48365 [file] [log] [blame]
Gunes Bayir7dc02342022-11-21 21:46:50 +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#ifndef SRC_DYNAMIC_FUSION_SKETCH_GPU_TEMPLATE_WRITER_CL_CLTEMPLATEDEPTHWISECONV2D
25#define SRC_DYNAMIC_FUSION_SKETCH_GPU_TEMPLATE_WRITER_CL_CLTEMPLATEDEPTHWISECONV2D
26
27#include "arm_compute/dynamic_fusion/sketch/attributes/DepthwiseConv2dAttributes.h"
28#include "src/dynamic_fusion/sketch/gpu/components/cl/ClComponentDepthwiseConv2d.h"
29#include "src/dynamic_fusion/sketch/gpu/template_writer/IGpuTemplateComponentWriter.h"
30
31namespace arm_compute
32{
33namespace experimental
34{
35namespace dynamic_fusion
36{
37class ClTemplateDepthwiseConv2d final : public IGpuTemplateComponentWriter
38{
39public:
40 using Attributes = ClComponentDepthwiseConv2d::Attributes;
41 using Settings = ClComponentDepthwiseConv2d::Settings;
42 /** Constructor
43 *
44 * Similar to @ref ClComponentDepthwiseConv2d::validate()
45 *
46 * @param[in] id Component id
47 * @param[in] tensors Tensor arguments to the components
48 * @param[in] attributes Component attributes
49 * @param[in] settings Component settings
50 */
51 ClTemplateDepthwiseConv2d(ComponentId id,
52 const ArgumentPack<ITensorInfo> &tensors,
53 const Attributes &attributes,
54 const Settings &settings);
55 /** Prevent instances of this class from being copy constructed */
56 ClTemplateDepthwiseConv2d(const ClTemplateDepthwiseConv2d &depthwise_conv2d) = delete;
57 /** Prevent instances of this class from being copied */
58 ClTemplateDepthwiseConv2d &operator=(const ClTemplateDepthwiseConv2d &depthwise_conv2d) = delete;
59 /** Allow instances of this class to be move constructed */
60 ClTemplateDepthwiseConv2d(ClTemplateDepthwiseConv2d &&depthwise_conv2d) = default;
61 /** Allow instances of this class to be moved */
62 ClTemplateDepthwiseConv2d &operator=(ClTemplateDepthwiseConv2d &&depthwise_conv2d) = default;
63 /** Generate kernel component name */
64 std::string get_name() const override;
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 /** Declare all variables used by the component in the @p vtable
73 *
74 * @param[out] vtable Variable table
75 * @param[in] comp_group Component group of which the component is a part of
76 */
77 void declare_variables(GpuKernelVariableTable &vtable, const ComponentGroup &comp_group) const override;
78 /** Generate the tag look-up table used to instantiate the component code.
79 *
80 * @param[in] vtable Variable table
81 * @param[in] comp_group Component group of which the component is a part of
82 *
83 * @return TagLUT Tag lookup table
84 */
85 TagLUT get_tag_lut(const GpuKernelVariableTable &vtable, const ComponentGroup &comp_group) const override;
86 /** Generate the build options used in the component
87 *
88 * @param[in] comp_group Component group of which the component is a part of
89 *
90 * @return CLBuildOptions Build options
91 */
92 CLBuildOptions get_build_options(const ComponentGroup &comp_group) const override;
93 /** Generate the component config id string used for tuning */
94 std::string get_config_id() const override;
95 /** Generate the header list used in the component */
96 std::set<std::string> get_headers_list() const override;
97 /** Generate the execution window for the component */
98 Window get_window() const override;
99
100private:
101 const ITensorInfo *_src;
102 const ITensorInfo *_weight;
103 const ITensorInfo *_bias;
104 const ITensorInfo *_dst;
105 Attributes _attributes;
106 Settings _settings;
107};
108} // namespace dynamic_fusion
109} // namespace experimental
110} // namespace arm_compute
111#endif /* SRC_DYNAMIC_FUSION_SKETCH_GPU_TEMPLATE_WRITER_CL_CLTEMPLATEDEPTHWISECONV2D */