tqchen commented on a change in pull request #4532: [WIP] Support standardize 
runtime module
URL: https://github.com/apache/incubator-tvm/pull/4532#discussion_r359060243
 
 

 ##########
 File path: src/codegen/codegen.cc
 ##########
 @@ -58,19 +61,141 @@ runtime::Module Build(const Array<LoweredFunc>& funcs,
   return m;
 }
 
+/*! \brief Helper class to construct module import relationship and serialize 
module */
+class ModuleGraph {
 
 Review comment:
   Can use a function, see 
   
   Likely we do not need a class, see the comments below for some 
simplifications
   try to simplify the algorithm a bit(without DFS callback)
   
   ```c++
   
   void ExportToBinary(Stream* strm) {
      // construct module to index
      std::unordered_map<ModuleNode*, size_t> mod2index;
      // index -> module
       std::vector<Module> modvec;
       // DFS create index, 
       CreateModuleIndex(root, &modvec, &mod2index);
       // create import tree into CSR matrix (each row is a parent, the values 
are indices of its children)
       // iterate over modvec, use mod2index to find the corresponding index.
       CreateImportTree(modvec, mod2index, &csr_row_ptr, &csr_value);
       // loop over the modvec and serialize modules
       // export import tree
   }
   ```
   

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


With regards,
Apache Git Services

Reply via email to