This is an automated email from the ASF dual-hosted git repository.

masahi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git


The following commit(s) were added to refs/heads/main by this push:
     new 8b30198  [FIX,PROFILING] Add extra precision to numbers when 
serializing to json (#10392)
8b30198 is described below

commit 8b3019845671af836169068ebbb2eef1d7131027
Author: Tristan Konolige <[email protected]>
AuthorDate: Fri Feb 25 15:38:59 2022 -0800

    [FIX,PROFILING] Add extra precision to numbers when serializing to json 
(#10392)
    
    Numbers were serialized with too little precision when serializing
    profiling reports to json. Deserialization can then sometimes round the
    number differently than if the full precision was available.
    
    Fixes #10382.
---
 src/runtime/profiling.cc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/runtime/profiling.cc b/src/runtime/profiling.cc
index 000f6ea..3401ea1 100644
--- a/src/runtime/profiling.cc
+++ b/src/runtime/profiling.cc
@@ -283,11 +283,11 @@ void print_metric(std::ostream& os, ObjectRef o) {
        << "\"" << Downcast<String>(o) << "\""
        << "}";
   } else if (const CountNode* n = o.as<CountNode>()) {
-    os << "{\"count\":" << std::to_string(n->value) << "}";
+    os << "{\"count\":" << n->value << "}";
   } else if (const DurationNode* n = o.as<DurationNode>()) {
-    os << "{\"microseconds\":" << std::to_string(n->microseconds) << "}";
+    os << "{\"microseconds\":" << std::setprecision(17) << std::fixed << 
n->microseconds << "}";
   } else if (const PercentNode* n = o.as<PercentNode>()) {
-    os << "{\"percent\":" << std::to_string(n->percent) << "}";
+    os << "{\"percent\":" << std::setprecision(17) << std::fixed << n->percent 
<< "}";
   } else {
     LOG(FATAL) << "Unprintable type " << o->GetTypeKey();
   }

Reply via email to