MCPcopy Create free account
hub / github.com/MegEngine/MegCC / get_helper_module_str

Method get_helper_module_str

compiler/test/kernel/common/src/target_module.cpp:110–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108}
109
110std::string TargetModule::get_helper_module_str() const {
111 std::stringstream ss;
112 ss << "//! generated file by megcc, do not modify\n";
113 ss << "#include <unordered_map>\n";
114 ss << "#include <string>\n";
115 ss << "#include \"tinycv_c.h\" \n";
116 ss << "#include \"test/kernel/common/target_module.h\"\n";
117 ss << GenCommonInclude() << "\n";
118 for (auto& kv : m_kern_map) {
119 ss << "extern \"C\" " << GenCommonRet() << " " << kv.first << GenCommonCall()
120 << ";\n";
121 }
122 for (auto& kv : m_kern_init_map) {
123 ss << "extern \"C\" " << GenCommonRet() << " " << kv.first
124 << GenCommonInitCall() << ";\n";
125 }
126 for (auto& kv : m_kern_workspace_map) {
127 ss << "extern \"C\" " << GenCommonRet() << " " << kv.first
128 << GenCommonWorkspaceCall() << ";\n";
129 }
130 for (auto& kv : m_kern_deduce_layout_map) {
131 ss << "extern \"C\" " << GenCommonRet() << " " << kv.first
132 << GenCommonDeduceCall() << ";\n";
133 }
134 for (auto& kv : m_cv_sig_map) {
135 ss << "extern \"C\" "
136 << " void " << kv.second << ";\n";
137 }
138 ss << "namespace megcc{\n";
139 ss << "namespace test{\n";
140 ss << "std::unordered_map<std::string, StdKernelCall> "
141 "g_str_2_kern{";
142 for (auto& kv : m_kern_map) {
143 ss << "{\"" << kv.first << "\"," << kv.first << "},";
144 }
145 ss << "};\n";
146
147 ss << "std::unordered_map<std::string, StdKernelInitCall> "
148 "g_str_2_kern_init{";
149 for (auto& kv : m_kern_init_map) {
150 ss << "{\"" << kv.first << "\"," << kv.first << "},";
151 }
152 ss << "};\n";
153
154 ss << "std::unordered_map<std::string, StdKernelWorkspaceCall> "
155 "g_str_2_kern_workspace{";
156 for (auto& kv : m_kern_workspace_map) {
157 ss << "{\"" << kv.first << "\"," << kv.first << "},";
158 }
159 ss << "};\n";
160
161 ss << "std::unordered_map<std::string, StdKernelDeduceCall> "
162 "g_str_2_kern_deduce{";
163 for (auto& kv : m_kern_deduce_layout_map) {
164 ss << "{\"" << kv.first << "\"," << kv.first << "},";
165 }
166 ss << "};\n";
167

Callers

nothing calls this directly

Calls 6

GenCommonIncludeFunction · 0.85
GenCommonRetFunction · 0.85
GenCommonCallFunction · 0.85
GenCommonInitCallFunction · 0.85
GenCommonWorkspaceCallFunction · 0.85
GenCommonDeduceCallFunction · 0.85

Tested by

no test coverage detected