comaniac commented on a change in pull request #9846:
URL: https://github.com/apache/tvm/pull/9846#discussion_r783572654



##########
File path: python/tvm/contrib/pipeline_executor.py
##########
@@ -125,6 +130,33 @@ def get_input_pipeline_map(self, name):
         """
         return self._get_input_pipeline_map(name)
 
+    def get_params_group_pipeline_map(self, name):
+        """Using the "name" of parameters group to get the corresponding 
runtime module index.
+        Returns
+        -------
+        Runtime module index: Integer
+            Returning the index of the runtime module.
+        """
+        return self._get_params_group_pipeline_map(name)
+
+    def set_params(self, params_group_name, params_data):
+        """Pipeline executor uses a map of parameters groups and module 
indexes to support
+        the "on the fly" parameters setting. For example, in order to declare 
that runtime
+        module 1 using group parameters named "param0", pipeline executor maps 
the parameters
+        group named "param0" with runtime 1.  This function is used to set 
parameters into
+        to correct runtime module by using the parameters group name.
+        ----------
+        params_group_name : str
+            It is the parameters group name.
+        params_data : dict of str to NDArray
+            There is a list of parameters data and params key name.
+        """
+        if not params_data:
+            raise RuntimeError('"params_data is None!"')

Review comment:
       It's not "None"...
   ```suggestion
               raise RuntimeError('"params_data is empty!"')
   ```

##########
File path: python/tvm/contrib/pipeline_executor.py
##########
@@ -125,6 +130,33 @@ def get_input_pipeline_map(self, name):
         """
         return self._get_input_pipeline_map(name)
 
+    def get_params_group_pipeline_map(self, name):
+        """Using the "name" of parameters group to get the corresponding 
runtime module index.
+        Returns
+        -------
+        Runtime module index: Integer
+            Returning the index of the runtime module.
+        """

Review comment:
       ```suggestion
           """Use the name of the parameters group to get the corresponding 
runtime module index.
   
           Parameters
           ----------
           name: str
               The parameter group name.
   
           Returns
           -------
           module_index: int
               The index of the runtime module.
           """
   ```

##########
File path: python/tvm/contrib/pipeline_executor.py
##########
@@ -529,8 +583,12 @@ def __getitem__(self, key):
                 return self.input_bindings
             if key == "output":
                 return self.output_bindings
+            if key == "param_group":
+                return self.param_group_bindings
+
+            raise RuntimeError(f"{key} not found!")
 
-        raise RuntimeError(f"{key} not found.")
+        raise RuntimeError('The data type of "key" is not supported!')

Review comment:
       ```suggestion
           raise RuntimeError(f'The key type "{type(key)}" is not supported!')
   ```

##########
File path: python/tvm/contrib/pipeline_executor.py
##########
@@ -125,6 +130,33 @@ def get_input_pipeline_map(self, name):
         """
         return self._get_input_pipeline_map(name)
 
+    def get_params_group_pipeline_map(self, name):
+        """Using the "name" of parameters group to get the corresponding 
runtime module index.
+        Returns
+        -------
+        Runtime module index: Integer
+            Returning the index of the runtime module.
+        """
+        return self._get_params_group_pipeline_map(name)
+
+    def set_params(self, params_group_name, params_data):
+        """Pipeline executor uses a map of parameters groups and module 
indexes to support
+        the "on the fly" parameters setting. For example, in order to declare 
that runtime
+        module 1 using group parameters named "param0", pipeline executor maps 
the parameters
+        group named "param0" with runtime 1.  This function is used to set 
parameters into
+        to correct runtime module by using the parameters group name.
+        ----------
+        params_group_name : str
+            It is the parameters group name.
+        params_data : dict of str to NDArray
+            There is a list of parameters data and params key name.
+        """

Review comment:
       I tried to refine the description but to be honest I don't understand 
what it means. How this function "declares that runtime module 1 using group 
parameters named param0"? I didn't see module 1 in the function argument.
   
   ```suggestion
           """Pipeline executor uses a map of parameters groups and module 
indexes to support
           the "on the fly" parameters setting. For example, users can bind the 
parameter group "param0"
           to the parameters of the 1st module. This function is used to set 
parameters into
           to correct runtime module by using the parameters group name.
           ----------
           params_group_name : str
               The parameters group name.
   
           params_data : Dict[str, NDArray]
               A map from parameter name to data.
           """
   ```

##########
File path: src/runtime/pipeline/pipeline_struct.h
##########
@@ -251,6 +251,48 @@ struct InputConnectionConfig {
   }
 };
 
+/*!
+ * \brief A map includes global module parameters groups and graph modudles.
+ */
+struct ParamConnectionConfig {
+  /*!\brief A key is the name of a global module parameters group . the value 
is the
+   * index of a runtime module.
+   */

Review comment:
       ```suggestion
     /*! \brief Mapping from the name of a global module parameters group to 
the index of a runtime module. */
   ```

##########
File path: python/tvm/contrib/pipeline_executor.py
##########
@@ -311,9 +343,20 @@ def connect(self, binding):
             if self.io_owner == binding.io_owner:
                 raise RuntimeError("Can not bind itself.")
 
+            if self.io_type == "param" and not 
self.is_pipeline_executor_interface():
+                raise RuntimeError(
+                    'The "param" binding can only be used by a pipeline 
executor interface!'
+                )
+
             if not self.is_pipeline_executor_interface() and self.io_type == 
"input":
                 raise RuntimeError("Module can only bind from output 
interface!")
 
+            if self.io_type == "param" and binding.io_type != "param":
+                raise RuntimeError(
+                    'A global "param" interface can only be bind with a module 
\
+                                     "param" interface!'

Review comment:
       ```suggestion
                       'A global "param" interface can only be bind with a 
module'
                       '"param" interface!'
   ```

##########
File path: src/runtime/pipeline/pipeline_executor.h
##########
@@ -75,14 +75,23 @@ class TVM_DLL PipelineExecutor : public ModuleNode {
    * \param The global input name.
    * \return Returning the index and the input interface name of corresponding 
subgraph.
    */
-  Array<String> GetInputPipeplineMapping(std::string input_name);
+  Array<String> GetInputPipeplineMap(std::string input_name);
+  /*!
+   * \brief This function return a module index for the global parameters 
group name.
+   *  return Returning a runtime module index.

Review comment:
       ```suggestion
      * \param ???
      * \return Returning a runtime module index.
   ```

##########
File path: src/runtime/pipeline/pipeline_executor.h
##########
@@ -75,14 +75,23 @@ class TVM_DLL PipelineExecutor : public ModuleNode {
    * \param The global input name.
    * \return Returning the index and the input interface name of corresponding 
subgraph.
    */
-  Array<String> GetInputPipeplineMapping(std::string input_name);
+  Array<String> GetInputPipeplineMap(std::string input_name);
+  /*!
+   * \brief This function return a module index for the global parameters 
group name.
+   *  return Returning a runtime module index.
+   */
+  int GetParamsGroupPipelineMap(const std::string& name);
+  /*!
+   * \brief Use the parameters group name to get the specific backend runtime 
then use
+   *  the param_key_name to set param data for the said backend runtime.
+   */

Review comment:
       add \param and \return




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