manupa-arm commented on a change in pull request #6950:
URL: https://github.com/apache/tvm/pull/6950#discussion_r556736580



##########
File path: src/relay/backend/contrib/codegen_c/codegen.cc
##########
@@ -229,25 +228,31 @@ class CSourceCodegen : public CSourceModuleCodegenBase {
     String func_name = std::get<1>(res);
 
     // Create headers
-    code_stream_ << "#include <cstring>\n";
-    code_stream_ << "#include <vector>\n";
+    code_stream_ << "#include <stdio.h>\n";
+    code_stream_ << "#include <stdlib.h>\n";
+    code_stream_ << "#include <string.h>\n";
     code_stream_ << "#include <tvm/runtime/c_runtime_api.h>\n";
-    code_stream_ << "#include <tvm/runtime/container.h>\n";
-    code_stream_ << "#include <tvm/runtime/packed_func.h>\n";
-    code_stream_ << "#include <dlpack/dlpack.h>\n";
-    code_stream_ << "using namespace tvm::runtime;\n";
+    code_stream_ << "#include <tvm/runtime/c_backend_api.h>\n";
+    code_stream_ << "#include <tvm/runtime/crt/module.h>\n";
+    if (!variables.empty()) {
+      // These are only needed to handle metadata copying
+      code_stream_ << "#include <tvm/runtime/container.h>\n";
+      code_stream_ << "#include <tvm/runtime/packed_func.h>\n";
+      code_stream_ << "#include <dlpack/dlpack.h>\n";
+      code_stream_ << "using namespace tvm::runtime;\n";

Review comment:
       Actually this segment is only to be generated in the presence of 
constant copying process and makes this source a C++ one. To this end, there is 
a init function that accepts "Array\<NDArray\> arr" (See in codegen_c.h) that 
is in that namespace. I could not think of a way to make it a C source 
immediately.
   
   Honestly, I was less worried about it as this is an example codegen and in 
utvm we dont want to be doing constant copying anyway. Therefore this segment 
will not be codegen'd. I understand its not ideal. However, the purpose of this 
test was to keep c-source base external codegen support (without constant 
copying -- which is controlled by constant extraction relay pass) in uTVM




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to