blob: fc8764c3e2eb4936ba218dc431d51ccee26638f4 [file] [log] [blame]
SiCong Li19844f62023-05-16 16:46:34 +01001/*
Gunes Bayir2b9fa592024-01-17 16:07:03 +00002 * Copyright (c) 2023-2024 Arm Limited.
SiCong Li19844f62023-05-16 16:46:34 +01003 *
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 */
Gunes Bayir2b9fa592024-01-17 16:07:03 +000024#ifndef ACL_SRC_DYNAMIC_FUSION_SKETCH_GPU_CKW_DRIVER_GPUCKWVARIABLETABLE_H
25#define ACL_SRC_DYNAMIC_FUSION_SKETCH_GPU_CKW_DRIVER_GPUCKWVARIABLETABLE_H
SiCong Li19844f62023-05-16 16:46:34 +010026
SiCong Li19844f62023-05-16 16:46:34 +010027#include "arm_compute/core/ITensorInfo.h"
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010028
SiCong Li23882a92023-06-28 09:49:45 +010029#include "src/dynamic_fusion/sketch/gpu/ckw_driver/GpuCkwComponentArgument.h"
SiCong Li19844f62023-05-16 16:46:34 +010030
31#include <map>
32
SiCong Li19844f62023-05-16 16:46:34 +010033namespace arm_compute
34{
35namespace experimental
36{
37namespace dynamic_fusion
38{
39class GpuKernelComponentGroup;
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010040class GpuCkwScopedKernelWriter;
SiCong Li19844f62023-05-16 16:46:34 +010041
42/** A table of all the variables used in the kernel.
43 *
44 * It determines whether we create an virtual tensor var or a user tensor var
45 * It avoids duplicating variables for the same tensors (Tensors with the same id)
46 * Each kernel has exactly one variable table.
47 */
48class GpuCkwVariableTable
49{
50public:
51 /** Declare a kernel component variable(argument) for the corresponding tensor info.
52 *
53 * @param[in] comp_group Component group the tensor belongs to
54 * @param[in] writer Compute Kernel Writer
55 * @param[in] tensor Tensor info with which the new variable is associated
56 * @param[in] alias Alias for the variable. Will be used as part of the variable name
57 *
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010058 * @return GpuCkwComponentArgument*
SiCong Li19844f62023-05-16 16:46:34 +010059 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010060 GpuCkwComponentArgument *declare_variable(const GpuKernelComponentGroup &comp_group,
61 GpuCkwScopedKernelWriter &writer,
62 const ITensorInfo *tensor,
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010063 const std::string &alias = "unnamed");
SiCong Li19844f62023-05-16 16:46:34 +010064
65private:
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010066 std::map<ITensorInfo::Id, GpuCkwComponentArgument> _vars{};
SiCong Li19844f62023-05-16 16:46:34 +010067};
68
69} // namespace dynamic_fusion
70} // namespace experimental
71} // namespace arm_compute
Gunes Bayir2b9fa592024-01-17 16:07:03 +000072#endif // ACL_SRC_DYNAMIC_FUSION_SKETCH_GPU_CKW_DRIVER_GPUCKWVARIABLETABLE_H