This is an automated email from the ASF dual-hosted git repository.
andrewzhaoluo pushed a commit to branch aluo/run-individual-node
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/aluo/run-individual-node by
this push:
new ab98b150be secondary commit
ab98b150be is described below
commit ab98b150be7ed2b9c9e6d942837403c96d191d70
Author: Andrew Zhao Luo <[email protected]>
AuthorDate: Tue Apr 12 16:29:44 2022 -0700
secondary commit
---
python/tvm/contrib/debugger/debug_executor.py | 16 ++++++++++++++++
.../graph_executor/debug/graph_executor_debug.cc | 18 ++++++++++++++++--
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/python/tvm/contrib/debugger/debug_executor.py
b/python/tvm/contrib/debugger/debug_executor.py
index 12152e9de1..f40a2880b1 100644
--- a/python/tvm/contrib/debugger/debug_executor.py
+++ b/python/tvm/contrib/debugger/debug_executor.py
@@ -111,6 +111,7 @@ class GraphModuleDebug(graph_executor.GraphModule):
self._dump_root = dump_root
self._dump_path = None
self._run_individual = module["run_individual"]
+ self._run_individual_node = module["run_individual_node"]
self._debug_get_output = module["debug_get_output"]
self._execute_node = module["execute_node"]
self._get_node_output = module["get_node_output"]
@@ -281,6 +282,21 @@ class GraphModuleDebug(graph_executor.GraphModule):
ret = self._run_individual(number, repeat, min_repeat_ms)
return ret.strip(",").split(",") if ret else []
+ def run_individual_node(self, index, number, repeat=1, min_repeat_ms=0):
+ """Results are returned as serialized strings which we deserialize."""
+ ret = self._run_individual_node(index, number, repeat, min_repeat_ms)
+ answer = []
+ for line in ret.split("\n"):
+ cur_results = []
+ if line.strip() == "":
+ continue
+ for value in line.split(","):
+ if value.strip() == "":
+ continue
+ cur_results.append(float(value))
+ answer.append(cur_results)
+ return answer
+
def profile(self, collectors=None, **input_dict):
"""Run forward execution of the graph and collect overall and per-op
performance metrics.
diff --git a/src/runtime/graph_executor/debug/graph_executor_debug.cc
b/src/runtime/graph_executor/debug/graph_executor_debug.cc
index dd95478e17..e1a0c3c490 100644
--- a/src/runtime/graph_executor/debug/graph_executor_debug.cc
+++ b/src/runtime/graph_executor/debug/graph_executor_debug.cc
@@ -95,7 +95,7 @@ class GraphExecutorDebug : public GraphExecutor {
std::vector<std::vector<double>> RunIndividualNode(int node_index, int
number, int repeat,
int min_repeat_ms) {
// warmup run
- GraphExecutor::Run();
+ // GraphExecutor::Run();
std::string tkey = module_->type_key();
// results_in_seconds[a][b] is the bth index run of the ath index repeat
@@ -394,7 +394,21 @@ PackedFunc GraphExecutorDebug::GetFunction(const
std::string& name,
ICHECK_GT(number, 0);
ICHECK_GT(repeat, 0);
ICHECK_GE(min_repeat_ms, 0);
- *rv = this->RunIndividualNode(node_index, number, repeat, min_repeat_ms);
+ std::vector<std::vector<double>> results =
+ this->RunIndividualNode(node_index, number, repeat, min_repeat_ms);
+
+ std::stringstream s;
+ s.precision(6); // down to microseconds
+
+ for (std::vector<double>& row : results) {
+ for (double cur : row) {
+ s << cur << ", ";
+ }
+ s << "\n";
+ }
+
+ // Have problems returning Integers and FloatImm so this is hack
+ *rv = s.str();
});
} else if (name == "profile") {
return
TypedPackedFunc<profiling::Report(Array<profiling::MetricCollector>)>(