diff --git a/aten/src/ATen/core/Formatting.cpp b/aten/src/ATen/core/Formatting.cpp index 82464070523..fad68601047 100644 --- a/aten/src/ATen/core/Formatting.cpp +++ b/aten/src/ATen/core/Formatting.cpp @@ -37,7 +37,7 @@ std::ostream& operator<<(std::ostream & out, const Scalar& s) { std::string toString(const Scalar& s) { std::stringstream out; out << s; - return out.str(); + return std::move(out).str(); } } namespace at { diff --git a/c10/util/StringUtil.h b/c10/util/StringUtil.h index 88a91c84ef0..8289fe453f4 100644 --- a/c10/util/StringUtil.h +++ b/c10/util/StringUtil.h @@ -124,7 +124,7 @@ inline std::string Join(const std::string& delimiter, const Container& v) { for (auto i = v.begin(); i != v.end(); ++i, --cnt) { s << (*i) << (cnt ? delimiter : ""); } - return s.str(); + return std::move(s).str(); } // Replace all occurrences of "from" substring to "to" string. diff --git a/torch/csrc/utils/python_dispatch.cpp b/torch/csrc/utils/python_dispatch.cpp index aa875680788..1dad860f6d9 100644 --- a/torch/csrc/utils/python_dispatch.cpp +++ b/torch/csrc/utils/python_dispatch.cpp @@ -638,7 +638,7 @@ void initDispatchBindings(PyObject* module) { if (!op.overload_name.empty()) { ss << "." << op.overload_name; } - names.emplace_back(ss.str()); + names.emplace_back(std::move(ss).str()); } return names;