Fix gradient refcounts in pybind and compiled autograd (#118817)

Pull Request resolved: https://github.com/pytorch/pytorch/pull/118817
Approved by: https://github.com/jansel
This commit is contained in:
Simon Fan
2024-02-06 17:47:51 -08:00
committed by PyTorch MergeBot
parent d85631b721
commit 8e14e1d514
2 changed files with 5 additions and 8 deletions

View File

@ -762,9 +762,7 @@ py::object invokeOperatorFromPython(
py::args args,
const py::kwargs& kwargs,
c10::optional<c10::DispatchKey> dk) {
auto opWithStack = getOpWithStack(operations, args, kwargs);
std::shared_ptr<Operator> found_op = std::get<0>(opWithStack);
Stack stack = std::get<1>(opWithStack);
auto [found_op, stack] = getOpWithStack(operations, args, kwargs);
{
pybind11::gil_scoped_release no_gil_guard;
if (dk) {