tvm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [incubator-tvm] masahi commented on a change in pull request #5493: [REFACTOR][BOYC] Non recursive partitioning
Date Fri, 01 May 2020 12:05:21 GMT

masahi commented on a change in pull request #5493:
URL: https://github.com/apache/incubator-tvm/pull/5493#discussion_r418515180



##########
File path: src/relay/transforms/partition_graph.cc
##########
@@ -470,115 +353,82 @@ class Partitioner : public ExprMutator {
   Expr GetFunctionOutput(AnnotatedRegion region, const Expr& end_arg) {
     Expr arg = Downcast<Call>(end_arg)->args[0];
     // Function has one output.
-    if (region_return_indices_[region].size() == 1) {
-      return region_function_calls[region];
+    if (region_func_meta_[region].out_expr_indices.size() == 1) {
+      return region_func_meta_[region].func_call;
     }
+
     // Function has multiple outputs.
     // Use already made TupleGetItem.
-    if (region_return_tuplegetitem_.count(region) &&
-        region_return_tuplegetitem_[region].count(arg)) {
-      return region_return_tuplegetitem_[region][arg];
+    if (region_func_meta_[region].out_expr_indices.count(arg) &&
+        region_func_meta_[region].out_expr_indices[arg].second.defined()) {
+      return region_func_meta_[region].out_expr_indices[arg].second;
     }
     // Create new TupleGetItem.
-    CHECK(region_return_indices_.count(region) &&
-          region_return_indices_[region].count(arg));
-    int index = region_return_indices_[region][arg];
+    CHECK(region_func_meta_[region].out_expr_indices.count(arg));
+    int index = region_func_meta_[region].out_expr_indices[arg].first;
 
-    auto func_call = region_function_calls[region];
+    auto func_call = region_func_meta_[region].func_call;
     auto tuple_get_item_ = TupleGetItem(func_call, index);
     tuple_get_item_->checked_type_ = arg->checked_type_;
-    region_return_tuplegetitem_[region][arg] = tuple_get_item_;
+    region_func_meta_[region].out_expr_indices[arg].second = tuple_get_item_;
     return std::move(tuple_get_item_);
   }
 
-  /*!
-   * \brief This map maintains the already created function calls.
-   * This is required in the multi-output scenario, to link rest of the outputs
-   * to call
-   */
-  std::unordered_map<AnnotatedRegion, Call, ObjectHash, ObjectEqual> region_function_calls;
-
-  /*!
-   * \brief This map maintains arguments (of region) visits through visitor
-   * patterns. Those arguement var and expression will be used to when creating
-   * the function.
-   */
-  std::unordered_map<AnnotatedRegion, std::vector<std::pair<Var, Expr>>, ObjectHash,
ObjectEqual>
-      region_args;
-
-  /*!
-   * \brief This map maintains the index of an output in the subgraph function
-   * for a given region. If there are multiple entries for a region, then the
-   * function has a tuple of multiple outputs for its return.
-   */
-  using RegionRetIndexMap = std::unordered_map<Expr, int, ObjectHash, ObjectEqual>;
-  std::unordered_map<AnnotatedRegion, RegionRetIndexMap, ObjectHash, ObjectEqual>
-      region_return_indices_;
+  /*! \brief Map from each region to its metadata of the generated function. */
+  std::unordered_map<AnnotatedRegion, RegionFuncMetadata, ObjectHash, ObjectEqual>
+      region_func_meta_;
 
-  /*!
-   * \brief This map holds already created TupleGetItem nodes for accessing
-   * outputs of a function.
-   */
-  using RegionRetTupleGetItemMap = std::unordered_map<Expr, TupleGetItem, ObjectHash,
ObjectEqual>;
-  std::unordered_map<AnnotatedRegion, RegionRetTupleGetItemMap, ObjectHash, ObjectEqual>
-      region_return_tuplegetitem_;
-
-  /*!
-   * \brief Each region set is associated with a function in the module.
+  /*! \brief Each region set is associated with a function in the module.
    * This map maintains the mapping between regionsets and the function it
    * belongs to
    */
   std::unordered_map<AnnotatedRegionSet, BaseFunc, ObjectHash, ObjectEqual> regions_sets_;
 
-  /*!\brief Cache the output that is shared by different nodes. */
-  using RegionOutputMap = std::unordered_map<AnnotatedRegion, Var, ObjectHash, ObjectEqual>;
-  std::unordered_map<Expr, RegionOutputMap, ObjectHash, ObjectEqual> shared_output_;
-
   /*!\brief The IRModule used for partitioning. */
   IRModule module_;
 };
 
-class DefaultRemover : public ExprMutator {
- public:
-  explicit DefaultRemover(const IRModule& module) : module_(module) {}
+IRModule Remove(IRModule module) {

Review comment:
       Remove what? Please come up a better name for this




----------------------------------------------------------------
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:
users@infra.apache.org



Mime
View raw message