Various C++ code fixes in LSAN integration (#165818)

This PR extracts the C++ code fixes from #154584, which are fixes in enabling LSAN.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/165818
Approved by: https://github.com/ezyang
This commit is contained in:
Yuanyuan Chen
2025-10-18 17:59:23 +00:00
committed by PyTorch MergeBot
parent d14cbb4476
commit 032bed95cd
2 changed files with 3 additions and 3 deletions

View File

@ -241,7 +241,7 @@ static PyObject* THPModule_initExtension(
END_HANDLE_TH_ERRORS
}
// The idea behind these two functions is to make it easy to test if we are
// The idea behind these functions is to make it easy to test if we are
// built with ASAN: they're designed not to crash if ASAN is not enabled, but
// to trigger ASAN if it is enabled. This lets us run a "canary" tests which
// checks if our build environment is misconfigured.

View File

@ -876,7 +876,7 @@ inline Variable make_variable_non_differentiable_view(
/*version_counter=*/impl::version_counter(base),
/*allow_tensor_metadata_change=*/allow_tensor_metadata_change);
data_impl_copy->set_autograd_meta(nullptr);
return Variable(data_impl_copy);
return Variable(std::move(data_impl_copy));
}
return Variable();
}
@ -935,7 +935,7 @@ inline Variable make_variable(
/*allow_tensor_metadata_change=*/allow_tensor_metadata_change);
data_impl_copy->set_autograd_meta(std::make_unique<AutogradMeta>(
data_impl_copy.get(), false, std::move(gradient_edge)));
return Variable(data_impl_copy);
return Variable(std::move(data_impl_copy));
}
return Variable();
}