This is an automated email from the ASF dual-hosted git repository. liuyizhi pushed a commit to branch v0.6 in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git
The following commit(s) were added to refs/heads/v0.6 by this push: new 4d16474 [BACKPORT-0.6][NODE][Serialization]fix serialization precision loss in float (#5860) 4d16474 is described below commit 4d164740c581b3e10c95a32e1d86d20cef14f582 Author: Yizhi Liu <liuyi...@apache.org> AuthorDate: Sat Jun 20 17:02:02 2020 -0700 [BACKPORT-0.6][NODE][Serialization]fix serialization precision loss in float (#5860) Co-authored-by: LaiyuanGong <30686426+hisif...@users.noreply.github.com> Co-authored-by: LaiyuanGong <30686426+hisif...@users.noreply.github.com> --- src/node/serialization.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/node/serialization.cc b/src/node/serialization.cc index d270e72..cb310eb 100644 --- a/src/node/serialization.cc +++ b/src/node/serialization.cc @@ -167,7 +167,11 @@ class JSONAttrGetter : public AttrVisitor { ReflectionVTable* reflection_ = ReflectionVTable::Global(); void Visit(const char* key, double* value) final { - node_->attrs[key] = std::to_string(*value); + std::ostringstream s; + // Type <double> have approximately 16 decimal digits + s.precision(16); + s << (*value); + node_->attrs[key] = s.str(); } void Visit(const char* key, int64_t* value) final { node_->attrs[key] = std::to_string(*value);