diff --git a/torch/csrc/jit/ir/ir.cpp b/torch/csrc/jit/ir/ir.cpp index ee51e5c29e77..0ddaebfe724b 100644 --- a/torch/csrc/jit/ir/ir.cpp +++ b/torch/csrc/jit/ir/ir.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -891,6 +892,13 @@ Value* Value::setDebugName(const std::string& name) { std::string replacement_name; do { std::stringstream ss; +#ifndef _WIN32 + // Protect 12345 integer from becoming "1,2345" if some other process sets + // global locale For more details see + // https://github.com/pytorch/pytorch/issues/79583#issuecomment-1161260061 + static std::locale c_locale("C"); + ss.imbue(c_locale); +#endif ss << name_base << "." << suffix++; replacement_name = ss.str(); } while (names.count(replacement_name) > 0);