Enable move warnings for torch targets (#149923)

This PR enables more move warnings for torch targets and fixes some code.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/149923
Approved by: https://github.com/malfet
This commit is contained in:
cyy
2025-03-26 08:38:13 +00:00
committed by PyTorch MergeBot
parent de68ddc68e
commit 79e8a69257
6 changed files with 40 additions and 3 deletions

View File

@ -117,7 +117,11 @@ py::object cast_sequence(std::vector<py::object> objs) {
for (const auto i : c10::irange(num_objs)) {
sequence[i] = std::move(objs[i]);
}
#if C10_RETURN_MOVE_IF_OLD_COMPILER
return std::move(sequence);
#else
return sequence;
#endif
}
py::object cast_dict(std::vector<py::object> objs) {
@ -127,7 +131,11 @@ py::object cast_dict(std::vector<py::object> objs) {
py::tuple obj = py::reinterpret_borrow<py::tuple>(objs[i]);
sequence[obj[0]] = obj[1];
}
#if C10_RETURN_MOVE_IF_OLD_COMPILER
return std::move(sequence);
#else
return sequence;
#endif
}
py::object unflatten_rec(