areusch commented on a change in pull request #7903:
URL: https://github.com/apache/tvm/pull/7903#discussion_r621323819



##########
File path: src/runtime/graph_executor/debug/graph_executor_debug.cc
##########
@@ -207,6 +200,42 @@ class GraphExecutorDebug : public GraphExecutor {
     return -1;
   }
 
+  /*!
+   * \brief Get number of outputs of the node.
+   * \param index The index of the node.
+   * \return The number of outputs.
+   */
+  size_t NodeGetNumOutputs(size_t index) {
+    if (nodes_[index].op_type != "tvm_op") return 1;
+    return static_cast<size_t>(nodes_[index].param.num_outputs);
+  }
+
+  /*!
+   * \brief Execute next node in the network.
+   *
+   * This method will execute next node assuming
+   * previous nodes has been executed and return output of index-th node.
+   *
+   * \param node_ind: The index of the node.
+   * \param output_ind: The output index of this node.
+   * \return Node outputs array.
+   */
+  NDArray ExecuteNextNodeGetOutputs(int node_ind, int output_ind) {
+    ICHECK_LT(static_cast<size_t>(node_ind), op_execs_.size());
+
+    // Reset execution.
+    if (node_ind < 0) {
+      last_executed_node_ = -1;
+      return NDArray();
+    }
+
+    if (node_ind > last_executed_node_) {

Review comment:
       I think it would be great if, in the PackedFunc API, we can separate the 
executing of layers from returning of outputs. it's confusing when the process 
to get output data is different depending which index you care about (which 
would be the case, in practice, with this API). can we have two functions:
   1. `execute_node(i)` runs nodes up to node `i`, returns nothing. it can be 
smart internally by tracking `last_executed_node_` and only running the 
additional nodes needed to increment `last_executed_node_` to `i`, when `i` > 
`last_executed_node_`.
   2. `get_output(i, j)`, which returns output `j` from node `i`. should assert 
`i == last_executed_node_`, which provides  a check that the returned value 
will be valid.




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


Reply via email to