Add missing moves to torch autograd (#92772)

Applies some additional std::move functions to torch/csrc/autograd to opportunities that were found via static analysis.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/92772
Approved by: https://github.com/ezyang
This commit is contained in:
Aaron Gokaslan
2023-01-24 02:01:49 +00:00
committed by PyTorch MergeBot
parent 2a8669c54c
commit 8c8cd9539d
16 changed files with 119 additions and 79 deletions

View File

@ -22,6 +22,7 @@
#include <memory> // for unique_ptr
#include <unordered_set>
#include <utility>
using namespace torch::autograd;
@ -108,7 +109,7 @@ void PythonEngine::thread_on_exception(
if (python_err) {
python_err->persist();
}
Engine::thread_on_exception(graph_task, fn, e);
Engine::thread_on_exception(std::move(graph_task), fn, e);
}
std::unique_ptr<AnomalyMetadata> PythonEngine::make_anomaly_metadata() {
@ -148,7 +149,7 @@ c10::intrusive_ptr<at::ivalue::Future> PythonEngine::execute_with_graph_task(
InputBuffer&& input_buffer) {
try {
return Engine::execute_with_graph_task(
graph_task, graph_root, std::move(input_buffer));
graph_task, std::move(graph_root), std::move(input_buffer));
} catch (python_error& e) {
pybind11::gil_scoped_acquire gil;
if (!PyErr_Occurred()) {