Skip to content

Commit

Permalink
address more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Tristan Konolige committed Apr 27, 2022
1 parent f79dd2f commit 63b8746
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion include/tvm/runtime/profiling.h
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ class CountNode : public Object {
/* \brief A ratio of two things. */
class RatioNode : public Object {
public:
/* The ratio as a floating point number. */
/* The ratio as a double precision floating point number. */
double ratio;

/* \brief Construct a new ratio.
Expand Down
1 change: 0 additions & 1 deletion python/tvm/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ def peakflops_fma_tir(
threads: T.int32,
) -> None:
# pylint: disable=invalid-name, missing-function-docstring
N = T.var("int32")
A = T.match_buffer(a, [threads, num_vector_registers, vec_width], "float32")
for t in T.parallel(threads):
for _j in range(iters):
Expand Down
14 changes: 11 additions & 3 deletions src/runtime/profiling.cc
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,14 @@ void print_metric(std::ostream& os, ObjectRef o) {
} else if (const CountNode* n = o.as<CountNode>()) {
os << "{\"count\":" << n->value << "}";
} else if (const DurationNode* n = o.as<DurationNode>()) {
os << "{\"microseconds\":" << std::setprecision(17) << std::fixed << n->microseconds << "}";
os << "{\"microseconds\":" << std::setprecision(std::numeric_limits<double>::max_digits10)
<< std::fixed << n->microseconds << "}";
} else if (const PercentNode* n = o.as<PercentNode>()) {
os << "{\"percent\":" << std::setprecision(17) << std::fixed << n->percent << "}";
os << "{\"percent\":" << std::setprecision(std::numeric_limits<double>::max_digits10)
<< std::fixed << n->percent << "}";
} else if (const RatioNode* n = o.as<RatioNode>()) {
os << "{\"ratio\":" << std::setprecision(17) << std::fixed << n->ratio << "}";
os << "{\"ratio\":" << std::setprecision(std::numeric_limits<double>::max_digits10)
<< std::fixed << n->ratio << "}";
} else {
LOG(FATAL) << "Unprintable type " << o->GetTypeKey();
}
Expand Down Expand Up @@ -377,6 +380,11 @@ ObjectRef AggregateMetric(const std::vector<ObjectRef>& metrics) {
}
return ObjectRef(make_object<RatioNode>(sum / metrics.size()));
} else if (metrics[0].as<StringObj>()) {
for (auto& m : metrics) {
ICHECK_EQ(Downcast<String>(metrics[0]), Downcast<String>(m))
<< "Report aggregation cannot handle metrics with different string values in an "
"aggregate."
}
// Assume all strings in metrics are the same.
return metrics[0];
} else {
Expand Down

0 comments on commit 63b8746

Please sign in to comment.