manupa-arm 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_r398522710
 
 

 ##########
 File path: src/relay/transforms/partition_graph.cc
 ##########
 @@ -102,61 +89,71 @@ class AnnotationChecker : public ExprVisitor {
   bool found_end_{false};
 };
 
-/*! \brief This class partitions the expr labeled with begin and end annoations
+/*! \brief This class partitions the expr labeled with begin and end 
annotations
  * into function containing multiple regions. Each region is labeled with
  * a compiler attribute so that it will be handled by any compilers that are 
not
  * in the TVM stack.
  *
- * TODO(@zhiics) This following algorithm is not adequate to handle all cases,
- * i.e. multiple `compiler_end` nodes.
+ * Input : A Relay module that have functions with disjoint annotated regions
+ *         using compiler_begin and compiler_end. There could be multiple 
outputs.
+ *
+ * Output : A Relay module with global functions for such disjoint annotated 
regions
+ *          with calls inserted at the respective location
+ *
+ * Dependencies : RegionSet Utility class.
+ *
+ * Methodology :
+ *      1) The RegionSet utility class is able to construct a collection of
+ *         nodes that are bound by a given annotation -- here we use 
compiler_begin
+ *         and compiler_end
+ *      2) Initially, for each function in the module RegionSets are populated.
+ *      3) Then, Vistor pass is traversed until a compiler_end node is 
encountered
+ *         that belongs to a "region".
+ *      4) When the first compiler_end of a given annotated region is found, a 
function is
+ *         formed and inserted.
+ *         a) if the region has multiple outputs, a Tuple node (capturing all 
outputs)
+ *            is returned.
+ *      5) Thereafter, if we encounter an another output of the same annotated 
region,
+ *         it is important to note that the function is already formed. 
Therefore, it will
+ *         lookup the function and add a TupleGetItemNode.
+ *          a) We will use the location index of "rets" of each "Region" of 
RegionSet
+ *             as TupleGetItemNode index.
+ *      6) Therefore, functions will be created for all annotated regions. The 
name for each
+ *         global function is created using "Region" id and the compiler name.
+ *
+ * Expected Usecase :
+ *      This pass is intended to run as the last pass in a series of passes as 
follows :
+ *      1) Annotate Supported Single Ops - annotated each single op with 
supported backends.
 
 Review comment:
   Removed the use-case segment. This is not needed now; as things are still in 
discussion as how this pass would potentially fit in the bigger picture.

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

Reply via email to