aboutsummaryrefslogtreecommitdiff
path: root/src/dynamic_fusion/sketch/gpu/GpuKernelSourceCode.h
blob: 24812cd8a746717bb2fe2e6968a429ca4cf5b4a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
 * Copyright (c) 2022-2023 Arm Limited.
 *
 * SPDX-License-Identifier: MIT
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to
 * deal in the Software without restriction, including without limitation the
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 * sell copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
#ifndef ACL_SRC_DYNAMIC_FUSION_SKETCH_GPU_GPUKERNELSOURCECODE
#define ACL_SRC_DYNAMIC_FUSION_SKETCH_GPU_GPUKERNELSOURCECODE

#include "arm_compute/core/CL/CLCompileContext.h"
#include "arm_compute/core/Window.h"

#include "src/dynamic_fusion/sketch/gpu/GpuKernelArgument.h"

#ifndef ACL_INTERNAL_TEST_CKW_IN_DF
#include <map>
#else // ACL_INTERNAL_TEST_CKW_IN_DF
#include <deque>
#endif // ACL_INTERNAL_TEST_CKW_IN_DF
#include <string>

namespace arm_compute
{
namespace experimental
{
namespace dynamic_fusion
{
/** The argument list of a @ref GpuKernelSourceCode */
#ifndef ACL_INTERNAL_TEST_CKW_IN_DF
using GpuKernelArgumentList = std::map<ITensorInfo::Id, GpuKernelArgument>;
#else  // ACL_INTERNAL_TEST_CKW_IN_DF
using GpuKernelArgumentList = std::deque<GpuKernelArgumentBinding>;
#endif // ACL_INTERNAL_TEST_CKW_IN_DF

/** Container of kernel code to be compiled and run in a @ref GpuUnitWorkload
 */
class GpuKernelSourceCode
{
public:
    /** Set kernel name */
    GpuKernelSourceCode &name(const std::string &n)
    {
        _name = n;
        return *this;
    }
    /** Set kernel code */
    GpuKernelSourceCode &code(const std::string &c)
    {
        _code = c;
        return *this;
    }
    /** Set kernel config id string */
    GpuKernelSourceCode &config_id(const std::string &c_id)
    {
        _config_id = c_id;
        return *this;
    }
    /** Set kernel build options */
    GpuKernelSourceCode &build_options(const CLBuildOptions &b_options)
    {
        _build_options = b_options;
        return *this;
    }
    /** Set kernel execution window */
    GpuKernelSourceCode &window(const Window &window)
    {
        _window = window;
        return *this;
    }
    /** Set kernel argument list */
    GpuKernelSourceCode &arguments(const GpuKernelArgumentList &arguments)
    {
        _arguments = arguments;
        return *this;
    }
    /** Get kernel name */
    std::string name() const
    {
        return _name;
    }
    /** Get kernel code */
    std::string code() const
    {
        return _code;
    }
    /** Get kernel config id string */
    std::string config_id() const
    {
        return _config_id;
    }
    /** Get kernel build options */
    const CLBuildOptions &build_options() const
    {
        return _build_options;
    }
    /** Get kernel execution window */
    const Window &window() const
    {
        return _window;
    }
    /** Get kernel argument list */
    const GpuKernelArgumentList &arguments() const
    {
        return _arguments;
    }

private:
    std::string           _name{};
    std::string           _code{};
    std::string           _config_id{};
    CLBuildOptions        _build_options{};
    Window                _window{};
    GpuKernelArgumentList _arguments{};
};
} // namespace dynamic_fusion
} // namespace experimental
} // namespace arm_compute
#endif /* ACL_SRC_DYNAMIC_FUSION_SKETCH_GPU_GPUKERNELSOURCECODE */