Skip to content

Commit

Permalink
Fix std::locale("") in profiling.cc (#11846)
Browse files Browse the repository at this point in the history
std::locale("") would failed  in some env like: LC_ALL=zh_CN.UTF-8 
`tvm._ffi.base.TVMError: locale: :facet::_S_create_c_locale name not valid>`

locale has its default constructor function, no need to set input to empty string `""`
  • Loading branch information
yogurfrul authored Jun 23, 2022
1 parent 79e64ad commit 12e8744
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/runtime/profiling.cc
Original file line number Diff line number Diff line change
Expand Up @@ -418,12 +418,12 @@ static String print_metric(ObjectRef metric) {
std::string val;
if (metric.as<CountNode>()) {
std::stringstream s;
s.imbue(std::locale("")); // for 1000s seperators
s.imbue(std::locale()); // for 1000s seperators
s << std::fixed << metric.as<CountNode>()->value;
val = s.str();
} else if (metric.as<DurationNode>()) {
std::stringstream s;
s.imbue(std::locale("")); // for 1000s seperators
s.imbue(std::locale()); // for 1000s seperators
s << std::fixed << std::setprecision(2) << metric.as<DurationNode>()->microseconds;
val = s.str();
} else if (metric.as<PercentNode>()) {
Expand All @@ -432,7 +432,7 @@ static String print_metric(ObjectRef metric) {
val = s.str();
} else if (metric.as<RatioNode>()) {
std::stringstream s;
s.imbue(std::locale("")); // for 1000s seperators
s.imbue(std::locale()); // for 1000s seperators
s << std::setprecision(2) << metric.as<RatioNode>()->ratio;
val = s.str();
} else if (metric.as<StringObj>()) {
Expand Down

0 comments on commit 12e8744

Please sign in to comment.