You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2021/12/16 02:02:54 UTC

[GitHub] [tvm] liangfu commented on a change in pull request #9751: [Runtime][Pipeline Executor] Add the map logic of global input and subgraph input.

liangfu commented on a change in pull request #9751:
URL: https://github.com/apache/tvm/pull/9751#discussion_r770168691



##########
File path: src/runtime/pipeline/pipeline_struct.h
##########
@@ -71,44 +77,53 @@ struct OutputBindings {
       // When this output is bound to a global interface, check if the global interface index
       // start from 0.
       if (global_binding) {
-        ICHECK(global_output_index >= 0);
+        ICHECK(global_output_index_ >= 0);
       } else {
         // When this output is bound to a graph executor module interface, check if the module
         // index start from 0.
         ICHECK(mod_idx >= 0);
-        bindings[mod_idx] = input_name;
+        bindings_[mod_idx] = input_name;
       }
     }
   }
 };
-
 /*!
  * \brief The binding information of all outputs of a module.
  */
-struct OutputMap {
-  /*! \brief Output binding map, 'int' is output interface index.*/
-  std::unordered_map<int, OutputBindings> output_binding_map;
-  OutputMap& operator=(const OutputMap& output) {
-    output_binding_map = output.output_binding_map;
+class ConfigOutputBindings {
+ private:
+  /*!\brief The map of output binding, 'int' is the output interface index.*/
+  std::unordered_map<int, ConfigBindings> output_binding_map_;

Review comment:
       put `private:` members on the bottom.

##########
File path: src/runtime/pipeline/pipeline_struct.h
##########
@@ -130,42 +145,113 @@ struct OutputMap {
         }
       }
       ICHECK(output_idx >= 0);
-      output_binding_map[output_idx] = binding;
+      output_binding_map_[output_idx] = binding;
     }
   }
 };
+
 /*!
  * \brief The binding or dependency information of each module output interface.
  */
-struct PipelineConfig {
-  /*!\brief The key is the module index, this variable records all module pipeline configuration
+class ConfigPipelineExecution {
+ private:
+  /*
+   *!\brief The key is the module index, this variable records all module pipeline configuration
    * information.
    */
-  std::unordered_map<int, OutputMap> config;
-  OutputMap& operator[](int key) {
-    ICHECK(config.find(key) != config.end());
-    return config[key];
-  }
+  std::unordered_map<int, ConfigOutputBindings> config_;

Review comment:
       put `private:` members on the bottom.

##########
File path: src/runtime/pipeline/pipeline_struct.h
##########
@@ -25,20 +25,26 @@
 #include <limits>
 #include <string>
 #include <unordered_map>
+#include <utility>
 #include <vector>
+#define GLOBAL_MODULE_INDEX -1
 /*!
  * \brief All binding information of a output interface.
  */
-struct OutputBindings {
+class ConfigBindings {
+ private:

Review comment:
       Please follow Google C++ code style guide to put `private:` members on the bottom.

##########
File path: python/tvm/contrib/pipeline_executor.py
##########
@@ -199,12 +229,48 @@ def is_pipeline_executor_interface(self):
             return not isinstance(self.io_owner, PipelineConfig.ModuleWrapper)
 
         def __repr__(self):
-            # Get all binding information.
-            ret = "  |{}: ".format(self.name)
+            # Geting the binding information in the form of text.
+            str_format = "  |{}: ".format(self.name)
             for binding in self.bindings:
                 mname, dname = binding.get_name()
-                ret += "{0}:{1} ".format(mname, dname)
-            return ret
+                str_format += "{0}:{1} ".format(mname, dname)
+
+            return str_format
+
+        def check_binding_dict(self, connection_dict):
+            """Checking the binding dictionary.
+            Parameter
+            ---------
+            connection_dict : Dict[str, Any]
+                It is a dictionary of module connections.
+            """
+            if "interface_name" not in connection_dict:
+                raise RuntimeError(f'"inteface_name" is missing in global config!"')

Review comment:
       There is no variable in the string, please remove the f prefix.
   ```suggestion
                   raise RuntimeError('"inteface_name" is missing in global config!"')
   ```




-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org