1 /* 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_GPUKERNELSOURCECODE 25 #define SRC_DYNAMIC_FUSION_SKETCH_GPU_GPUKERNELSOURCECODE 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" 30 31 #include <map> 32 #include <string> 33 34 namespace arm_compute 35 { 36 namespace experimental 37 { 38 namespace dynamic_fusion 39 { 40 /** The argument list of a @ref GpuKernelSourceCode */ 41 using GpuKernelArgumentList = std::map<ITensorInfo::Id, GpuKernelArgument>; 42 43 /** Container of kernel code to be compiled and run in a @ref GpuUnitWorkload 44 */ 45 class GpuKernelSourceCode 46 { 47 public: 48 /** Set kernel name */ name(const std::string & n)49 GpuKernelSourceCode &name(const std::string &n) 50 { 51 _name = n; 52 return *this; 53 } 54 /** Set kernel code */ code(const std::string & c)55 GpuKernelSourceCode &code(const std::string &c) 56 { 57 _code = c; 58 return *this; 59 } 60 /** Set kernel config id string */ config_id(const std::string & c_id)61 GpuKernelSourceCode &config_id(const std::string &c_id) 62 { 63 _config_id = c_id; 64 return *this; 65 } 66 /** Set kernel build options */ build_options(const CLBuildOptions & b_options)67 GpuKernelSourceCode &build_options(const CLBuildOptions &b_options) 68 { 69 _build_options = b_options; 70 return *this; 71 } 72 /** Set kernel execution window */ window(const Window & window)73 GpuKernelSourceCode &window(const Window &window) 74 { 75 _window = window; 76 return *this; 77 } 78 /** Set kernel argument list */ arguments(const GpuKernelArgumentList & arguments)79 GpuKernelSourceCode &arguments(const GpuKernelArgumentList &arguments) 80 { 81 _arguments = arguments; 82 return *this; 83 } 84 /** Get kernel name */ name()85 std::string name() const 86 { 87 return _name; 88 } 89 /** Get kernel code */ code()90 std::string code() const 91 { 92 return _code; 93 } 94 /** Get kernel config id string */ config_id()95 std::string config_id() const 96 { 97 return _config_id; 98 } 99 /** Get kernel build options */ build_options()100 const CLBuildOptions &build_options() const 101 { 102 return _build_options; 103 } 104 /** Get kernel execution window */ window()105 const Window &window() const 106 { 107 return _window; 108 } 109 /** Get kernel argument list */ arguments()110 const GpuKernelArgumentList &arguments() const 111 { 112 return _arguments; 113 } 114 115 private: 116 std::string _name{}; 117 std::string _code{}; 118 std::string _config_id{}; 119 CLBuildOptions _build_options{}; 120 Window _window{}; 121 GpuKernelArgumentList _arguments{}; 122 }; 123 } // namespace dynamic_fusion 124 } // namespace experimental 125 } // namespace arm_compute 126 #endif /* SRC_DYNAMIC_FUSION_SKETCH_GPU_GPUKERNELSOURCECODE */ 127