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 fcc169ab56 formatting returned double str, move to typed packed func
fcc169ab56 is described below
commit fcc169ab56b40ad437c42b15b17f4035a87be8cd
Author: Andrew Zhao Luo <[email protected]>
AuthorDate: Mon Apr 18 15:16:57 2022 -0700
formatting returned double str, move to typed packed func
---
.../graph_executor/debug/graph_executor_debug.cc | 50 +++++++++++-----------
1 file changed, 25 insertions(+), 25 deletions(-)
diff --git a/src/runtime/graph_executor/debug/graph_executor_debug.cc
b/src/runtime/graph_executor/debug/graph_executor_debug.cc
index e1a0c3c490..a5804bc668 100644
--- a/src/runtime/graph_executor/debug/graph_executor_debug.cc
+++ b/src/runtime/graph_executor/debug/graph_executor_debug.cc
@@ -384,32 +384,32 @@ PackedFunc GraphExecutorDebug::GetFunction(const
std::string& name,
*rv = this->RunIndividual(number, repeat, min_repeat_ms);
});
} else if (name == "run_individual_node") {
- return PackedFunc([sptr_to_self, this](TVMArgs args, TVMRetValue* rv) {
- int node_index = args[0];
- int number = args[1];
- int repeat = args[2];
- int min_repeat_ms = args[3];
- ICHECK_GE(node_index, 0);
- ICHECK_LT(node_index, nodes_.size());
- ICHECK_GT(number, 0);
- ICHECK_GT(repeat, 0);
- ICHECK_GE(min_repeat_ms, 0);
- 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";
- }
+ return TypedPackedFunc<std::string(int, int, int, int)>(
+ [sptr_to_self, this](int node_index, int number, int repeat, int
min_repeat_ms) {
+ ICHECK_GE(node_index, 0);
+ ICHECK_LT(node_index, nodes_.size());
+ ICHECK_GT(number, 0);
+ ICHECK_GT(repeat, 0);
+ ICHECK_GE(min_repeat_ms, 0);
+ std::vector<std::vector<double>> results =
+ this->RunIndividualNode(node_index, number, repeat,
min_repeat_ms);
+
+ // Have problems returning FloatImm so serialize to string results
as hack.
+ std::stringstream s;
+
+ // use maximum precision available and use fixed representation
+ s << std::fixed;
+ s.precision(std::numeric_limits<double>::max_digits10);
+
+ 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();
- });
+ return s.str();
+ });
} else if (name == "profile") {
return
TypedPackedFunc<profiling::Report(Array<profiling::MetricCollector>)>(
[sptr_to_self, this](Array<profiling::MetricCollector> collectors) {