SiCong Li | f44bbc5 | 2022-08-29 18:25:51 +0100 | [diff] [blame] | 1 | /* |
SiCong Li | 23882a9 | 2023-06-28 09:49:45 +0100 | [diff] [blame] | 2 | * Copyright (c) 2022-2023 Arm Limited. |
SiCong Li | f44bbc5 | 2022-08-29 18:25:51 +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 | */ |
| 24 | #ifndef SRC_DYNAMIC_FUSION_SKETCH_GPU_IGPUKERNELWRITER |
| 25 | #define SRC_DYNAMIC_FUSION_SKETCH_GPU_IGPUKERNELWRITER |
| 26 | |
| 27 | #include "arm_compute/core/CL/CLCompileContext.h" |
| 28 | #include "arm_compute/core/Window.h" |
| 29 | #include "src/dynamic_fusion/sketch/gpu/GpuKernelArgument.h" |
SiCong Li | 23882a9 | 2023-06-28 09:49:45 +0100 | [diff] [blame] | 30 | #include "src/dynamic_fusion/sketch/gpu/GpuKernelSourceCode.h" |
SiCong Li | f44bbc5 | 2022-08-29 18:25:51 +0100 | [diff] [blame] | 31 | |
| 32 | #include <map> |
| 33 | #include <string> |
SiCong Li | 23882a9 | 2023-06-28 09:49:45 +0100 | [diff] [blame] | 34 | #include <vector> |
SiCong Li | f44bbc5 | 2022-08-29 18:25:51 +0100 | [diff] [blame] | 35 | |
| 36 | namespace arm_compute |
| 37 | { |
| 38 | namespace experimental |
| 39 | { |
| 40 | namespace dynamic_fusion |
| 41 | { |
| 42 | /** An interface that can write a gpu kernel |
| 43 | */ |
| 44 | class IGpuKernelWriter |
| 45 | { |
| 46 | public: |
| 47 | /** Destructor */ |
| 48 | virtual ~IGpuKernelWriter() |
| 49 | { |
| 50 | } |
| 51 | /** Generate kernel name */ |
| 52 | virtual std::string get_name() = 0; |
| 53 | /** Generate kernel code */ |
| 54 | virtual std::string get_code() = 0; |
| 55 | /** Generate build options */ |
SiCong Li | 16b3752 | 2023-07-18 17:56:49 +0100 | [diff] [blame] | 56 | virtual CLBuildOptions get_build_options() |
| 57 | { |
| 58 | return {}; |
| 59 | } |
SiCong Li | f44bbc5 | 2022-08-29 18:25:51 +0100 | [diff] [blame] | 60 | /** Generate config id string of the entire kernel. This is used for tuning */ |
| 61 | virtual std::string get_config_id() = 0; |
| 62 | /** Generate execution window */ |
| 63 | virtual Window get_window() const = 0; |
SiCong Li | 23882a9 | 2023-06-28 09:49:45 +0100 | [diff] [blame] | 64 | /** Get the kernel argument lists of the kernel |
| 65 | * @deprecated To be removed along with ClTemplateWriter |
| 66 | */ |
| 67 | virtual std::map<ITensorInfo::Id, GpuKernelArgument> get_tensors() |
| 68 | { |
| 69 | return {}; |
| 70 | } |
| 71 | #ifdef ACL_INTERNAL_TEST_CKW_IN_DF |
| 72 | /** Get the flat list of arguments of the kernel*/ |
| 73 | virtual GpuKernelArgumentList get_kernel_arguments() |
| 74 | { |
| 75 | return {}; |
| 76 | } |
| 77 | #endif // ACL_INTERNAL_TEST_CKW_IN_DF |
SiCong Li | f44bbc5 | 2022-08-29 18:25:51 +0100 | [diff] [blame] | 78 | }; |
| 79 | |
| 80 | } // namespace dynamic_fusion |
| 81 | } // namespace experimental |
| 82 | } // namespace arm_compute |
| 83 | #endif /* SRC_DYNAMIC_FUSION_SKETCH_GPU_IGPUKERNELWRITER */ |