elvin-nnov commented on a change in pull request #7903:
URL: https://github.com/apache/tvm/pull/7903#discussion_r620878239
##########
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) {
Review comment:
forgotten function during refactoring? should be removed?
##########
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:
The PR looks almost good from my point of view, at the same time I would
fix something in the logic of this function.
There are two corner cases that might fail with current logic
1. if we pass index less than currently executed node, nothing will be
executed, but tensor value might be wrong because it might be overwritten by
next ones already
2. if we pass index bigger than `last_executed_node_+1`, wrong results can
be returned as well
I would recommend either return index from function's arguments and just has
internal mechanism of calculating what is a current index and which next layer
will be executed and returned. In this case we will have to care about stop
conditions and getting start from beginning for example by adding couple more
functions. That might be not elegant. Or we might not verify if desired layer
is following just after executed and make caller responsible for all
verification. And in this case the name of the function just should not contain
`next`. It should be something like
`ExecuteNodeGetOutput`/`execute_node_get_output`. And need to remove all
verification of `last_executed_node_`.
The second approach is simplier
--
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]