You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2020/01/08 17:00:08 UTC

[GitHub] [incubator-tvm] tqchen commented on a change in pull request #4657: [CodeGen] Generate blob use LLVM directly

tqchen commented on a change in pull request #4657: [CodeGen] Generate blob use LLVM directly
URL: https://github.com/apache/incubator-tvm/pull/4657#discussion_r364338087
 
 

 ##########
 File path: src/codegen/codegen.cc
 ##########
 @@ -211,5 +220,30 @@ std::string PackImportsToC(const runtime::Module& mod, bool system_lib) {
      << "#endif\n";
   return os.str();
 }
+
+runtime::Module PackImportsToLLVM(const runtime::Module& mod,
+                                  bool system_lib,
+                                  const std::string& target) {
+  std::string bin = SerializeModule(mod);
+
+  std::ostringstream os;
+  uint64_t nbytes = bin.length();
+  os << std::hex;
+  for (size_t i = 0; i < sizeof(nbytes); ++i) {
+    os << std::setfill('0') << std::setw(2) << ((nbytes >> (i * 8)) & 0xffUL);
+  }
+  for (size_t i = 0; i < bin.length(); ++i) {
+    int c = bin[i];
+    os << std::setfill('0') << std::setw(2) << (c & 0xff);
+  }
+
+  // Call codegen_blob to generate LLVM module
+  std::string codegen_f_name = "codegen.codegen_blob";
+  // the codegen function.
+  const PackedFunc* codegen_f = runtime::Registry::Get(codegen_f_name);
+  CHECK(codegen_f != nullptr)  << "codegen.codegen_blob is not presented.";
+  return (*codegen_f)(os.str(), system_lib, target);
 
 Review comment:
   Do we need to pass hex here? can we directly pass the binary blob to LLVM?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services