tvm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [incubator-tvm] zhiics commented on a change in pull request #5195: [RELAY] Fixes to MergeCompilerRegions
Date Wed, 01 Apr 2020 00:11:12 GMT
zhiics commented on a change in pull request #5195: [RELAY] Fixes to MergeCompilerRegions
URL: https://github.com/apache/incubator-tvm/pull/5195#discussion_r401284934
 
 

 ##########
 File path: src/relay/transforms/merge_compiler_regions.cc
 ##########
 @@ -86,126 +86,145 @@ class AnnotateRestDefault : public ExprMutator {
   }
 
   /*! \brief This function adds compiler ends to nodes that
-   * have a region AND they should not be arguments of the
-   * original function
+   * don't belong to a region already (default).
    * \param expr The expression to add a compiler end to.
    * \return expr The expression with or without a compiler end added.
    */
-  Expr AddCompilerEnd(const Expr& expr) {
-    auto region = regions_->GetRegion(expr);
-    auto visited_expr = VisitExpr(expr);
-
-    // The compiler ends are added to nodes that does have a region
-    // AND they should not be arguments of the original function
-    if (!region.defined() &&
-       std::find(func_->params.begin(),
-                 func_->params.end(), visited_expr)
-                   == func_->params.end()) {
-      return AddCompilerEnd_(visited_expr);
+  Expr InsertEnd(const Expr& expr) {
+    if (annotated_nodes_.find(expr) == annotated_nodes_.end() &&
+        !expr->IsInstance<VarNode>() && !expr->IsInstance<ConstantNode>())
{
+      const auto *end_op =
+        runtime::Registry::Get("relay.op.annotation._make.compiler_end");
+      CHECK(end_op);
+      Expr end = (*end_op)(expr, target_);
+      return end;
     }
-    return visited_expr;
+    return expr;
   }
 
-  Expr AddCompilerEnd_(const Expr& expr) {
-    const auto* end_op =
-      runtime::Registry::Get("relay.op.annotation._make.compiler_end");
-    CHECK(end_op);
-    Expr end = (*end_op)(expr, target_);
-    return end;
+  /*! \brief This function adds compiler begins to nodes that
+ * don't belong to a region already (default).
+ * \param expr The expression to add a compiler begin to.
+ * \return expr The expression with or without a compiler begin added.
+ */
+  Expr InsertBegin(const Expr& expr) {
+    const auto *begin_op =
 
 Review comment:
   const auto*

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


With regards,
Apache Git Services

Mime
View raw message