tqchen commented on code in PR #15244:
URL: https://github.com/apache/tvm/pull/15244#discussion_r1265542764


##########
src/target/codegen.cc:
##########
@@ -324,6 +333,46 @@ runtime::Module PackImportsToLLVM(const runtime::Module& 
mod, bool system_lib,
   return (*codegen_f)(blob_byte_array, system_lib, llvm_target_string, 
c_symbol_prefix);
 }
 
+struct Deleter {  // deleter
+  explicit Deleter(std::string file_name) { this->file_name = file_name; }
+  void operator()(FILE* p) const {
+    fclose(p);
+    ICHECK(remove(file_name.c_str()) == 0)
+        << "remove temporary file (" << file_name << ") unsuccessfully";
+  }
+  std::string file_name;
+};
+
+std::string SerializeModuleToBase64(tvm::runtime::Module module) {
+  static const runtime::PackedFunc* f_to_str = 
runtime::Registry::Get("serialize_runtime_module");
+  ICHECK(f_to_str) << "IndexError: Cannot find the packed function "
+                      "`serialize_runtime_module` in the global registry";
+  return (*f_to_str)(module);
+}
+
+tvm::runtime::Module DeserializeModuleFromBase64(std::string state) {

Review Comment:
   state=> base64
   
   - For loading (back to IRModule), actually we do not want to export load it 
as so, instead, we would like to directly load back, this is something that 
have not been implemented but likely very related with the process  blob
   



##########
src/target/codegen.cc:
##########
@@ -83,17 +85,19 @@ class ModuleSerializer {
 
     for (const auto& group : mod_group_vec_) {
       ICHECK_NE(group.size(), 0) << "Every allocated group must have at least 
one module";
-      if (!group[0]->IsDSOExportable()) {

Review Comment:
   We need two modes here. If the 
   
   - export mode (when we call export_library): Then we save as lib as long as 
it is DSOExportable.
   - serialize mode (when we serialize): Always serialize when it is binary 
serializable. report an error when it is not, since we cannot recover the model 
   



-- 
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.

To unsubscribe, e-mail: [email protected]

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

Reply via email to