SiCong Li | 19844f6 | 2023-05-16 16:46:34 +0100 | [diff] [blame] | 1 | /* |
Gunes Bayir | 2b9fa59 | 2024-01-17 16:07:03 +0000 | [diff] [blame^] | 2 | * Copyright (c) 2023-2024 Arm Limited. |
SiCong Li | 19844f6 | 2023-05-16 16:46:34 +0100 | [diff] [blame] | 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 | */ |
Gunes Bayir | 2b9fa59 | 2024-01-17 16:07:03 +0000 | [diff] [blame^] | 24 | #ifndef ACL_SRC_DYNAMIC_FUSION_SKETCH_GPU_CKW_DRIVER_GPUCKWVARIABLETABLE_H |
| 25 | #define ACL_SRC_DYNAMIC_FUSION_SKETCH_GPU_CKW_DRIVER_GPUCKWVARIABLETABLE_H |
SiCong Li | 19844f6 | 2023-05-16 16:46:34 +0100 | [diff] [blame] | 26 | |
SiCong Li | 19844f6 | 2023-05-16 16:46:34 +0100 | [diff] [blame] | 27 | #include "arm_compute/core/ITensorInfo.h" |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 28 | |
SiCong Li | 23882a9 | 2023-06-28 09:49:45 +0100 | [diff] [blame] | 29 | #include "src/dynamic_fusion/sketch/gpu/ckw_driver/GpuCkwComponentArgument.h" |
SiCong Li | 19844f6 | 2023-05-16 16:46:34 +0100 | [diff] [blame] | 30 | |
| 31 | #include <map> |
| 32 | |
SiCong Li | 19844f6 | 2023-05-16 16:46:34 +0100 | [diff] [blame] | 33 | namespace arm_compute |
| 34 | { |
| 35 | namespace experimental |
| 36 | { |
| 37 | namespace dynamic_fusion |
| 38 | { |
| 39 | class GpuKernelComponentGroup; |
Viet-Hoa Do | ce3c48c | 2023-07-03 13:44:43 +0100 | [diff] [blame] | 40 | class GpuCkwScopedKernelWriter; |
SiCong Li | 19844f6 | 2023-05-16 16:46:34 +0100 | [diff] [blame] | 41 | |
| 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 | */ |
| 48 | class GpuCkwVariableTable |
| 49 | { |
| 50 | public: |
| 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 Do | ce3c48c | 2023-07-03 13:44:43 +0100 | [diff] [blame] | 58 | * @return GpuCkwComponentArgument* |
SiCong Li | 19844f6 | 2023-05-16 16:46:34 +0100 | [diff] [blame] | 59 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 60 | GpuCkwComponentArgument *declare_variable(const GpuKernelComponentGroup &comp_group, |
| 61 | GpuCkwScopedKernelWriter &writer, |
| 62 | const ITensorInfo *tensor, |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 63 | const std::string &alias = "unnamed"); |
SiCong Li | 19844f6 | 2023-05-16 16:46:34 +0100 | [diff] [blame] | 64 | |
| 65 | private: |
Viet-Hoa Do | ce3c48c | 2023-07-03 13:44:43 +0100 | [diff] [blame] | 66 | std::map<ITensorInfo::Id, GpuCkwComponentArgument> _vars{}; |
SiCong Li | 19844f6 | 2023-05-16 16:46:34 +0100 | [diff] [blame] | 67 | }; |
| 68 | |
| 69 | } // namespace dynamic_fusion |
| 70 | } // namespace experimental |
| 71 | } // namespace arm_compute |
Gunes Bayir | 2b9fa59 | 2024-01-17 16:07:03 +0000 | [diff] [blame^] | 72 | #endif // ACL_SRC_DYNAMIC_FUSION_SKETCH_GPU_CKW_DRIVER_GPUCKWVARIABLETABLE_H |