huajsj commented on a change in pull request #9108:
URL: https://github.com/apache/tvm/pull/9108#discussion_r724703283



##########
File path: src/runtime/pipeline/pipeline_executor.cc
##########
@@ -21,31 +21,51 @@
  * \file pipeline_executor.cc
  */
 #include "pipeline_executor.h"
-
 namespace tvm {
 namespace runtime {
-
-void PipelineRuntime::Init(const Array<tvm::runtime::Module>& modules,
-                           const std::string& pipeline_json) {
-  return;
-}
-
-/* GetFunction can not be pure abstract function, implement an empty function 
for now.
+/*!
+ * \brief Give frontends an access to packed functions.
+ * \param name The name of the function.
+ * \param sptr_to_self The pointer to the module node.
+ * \return The corresponding packed function.
  */
-PackedFunc PipelineRuntime::GetFunction(const std::string& name,
-                                        const ObjectPtr<Object>& sptr_to_self) 
{
+PackedFunc PipelineExecutor::GetFunction(const std::string& name,
+                                         const ObjectPtr<Object>& 
sptr_to_self) {
+  if (name == "get_num_outputs") {
+    return PackedFunc(
+        [sptr_to_self, this](TVMArgs args, TVMRetValue* rv) { *rv = 
this->NumOutputs(); });
+  } else {
+    LOG(FATAL) << "Unknown packed function: " << name;
+    return PackedFunc();
+  }
   return nullptr;
 }
+/*!
+ * \brief Initialize the pipeline executor with a list of modules to be 
pipelined
+ *  and config in JSON format.
+ * \param modules The module list used for building the pipeline.
+ * \param pipeline_json The configuration of modules dependencies.
+ */
+void PipelineExecutor::Init(const Array<Module>& modules, const std::string& 
pipeline_json) {
+  // Use JSONReader to load pipeline configuration.
+  std::istringstream is(pipeline_json);
+  dmlc::JSONReader reader(&is);
+  // When the value of 'modules' is empty, here need to load the modules from 
JSON.
+  this->Load(&reader, modules.empty());

Review comment:
       removed load_module, and create a new load_from_file logic to decouple 
"LoadFromFile" logic from "init" function to make code more clear, please check.




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