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



##########
File path: python/tvm/contrib/pipeline_executor.py
##########
@@ -86,8 +88,43 @@ class PipelineModule(object):
         Common interface for pipeline executor factory modules.
     """
 
-    def __init__(self, module):
-        self.module = module.module
+    def __init__(self, module=None):
+        self.module = module.module if module else None
+        self._get_num_outputs = None
+        # Get the packed functions from the pipeline executor.
+        self.load_functions()
+
+    def import_from_library(self, config_file_name):
+        """Import files to create pipeline executor.
+
+        Parameters
+        ----------
+        config_file_name : str
+            The configuration file path, the configuration file contains the
+            disk path of the parameter file, library file and JSON file。
+        """
+        # Create a empty PipelineExecutorFactoryModule.
+        pipeline_factory = PipelineExecutorFactoryModule()
+        # Load the configuration file to initialize a 
PipelineExecutorFactoryModule.
+        pipeline_factory.import_from_library(config_file_name)
+        self.module = pipeline_factory.module
+        # Get packed functions from the pipeline executor.
+        self.load_functions()
+
+    def load_functions(self):
+        # Get functions from the pipeline executor.
+        self._get_num_outputs = self.module["get_num_outputs"] if self.module 
else None
+
+    def get_num_outputs(self):
+        """Get the number of outputs.
+        Returns
+        -------
+        count : int
+            The number of outputs.
+        """
+        if not self._get_num_outputs:
+            raise RuntimeError(f"The pipeline executor has not been 
initialized.")
+        return self._get_num_outputs()

Review comment:
       fixed.




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