zhiics commented on a change in pull request #5143: [RELAY] Re-wrote the Graph
Partitioner to support multiple outputs
URL: https://github.com/apache/incubator-tvm/pull/5143#discussion_r398760603
##########
File path: src/relay/transforms/partition_graph.cc
##########
@@ -365,35 +374,113 @@ class Partitioner : public ExprMutator {
IRModule Partition() {
auto glob_funcs = module_->functions;
for (const auto& pair : glob_funcs) {
- if (auto* fn = pair.second.as<FunctionNode>()) {
+ if (auto *fn = pair.second.as<FunctionNode>()) {
auto func = GetRef<Function>(fn);
func = Function(func->params,
- VisitExpr(func->body),
- func->ret_type,
- func->type_params,
- func->attrs);
+ VisitExpr(func->body),
+ func->ret_type,
+ func->type_params,
+ func->attrs);
module_->Update(pair.first, func);
}
}
return module_;
}
private:
- int var_id_{0};
- int subgraph_id_{0};
- std::unordered_set<std::shared_ptr<Subgraph>> subgraphs_;
+ /*!
+ * \brief Get the region an expression belongs to
+ * if its in a region.
+ */
+ AnnotatedRegion GetRegion(const Expr& e) {
+ for (auto sg_set_it : regions_sets_) {
+ auto sg_set = sg_set_it.first;
+ AnnotatedRegion sg = sg_set->GetRegion(e);
+ if (sg.defined()) {
+ return sg;
+ }
+ }
+ return AnnotatedRegion(nullptr);
+ }
+
+ /*!
Review comment:
align
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services