Reset grad attribute when called using del (#16525)
authorbhushan <bhushan.s.94@gmail.com>
Tue, 19 Feb 2019 12:24:45 +0000 (04:24 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Tue, 19 Feb 2019 12:33:57 +0000 (04:33 -0800)
commit7e5442f90099e27d285e585b8d4e3ee05eb4ac4e
tree6995954034fe5c8a55cf6bdb487fb2919d8bee67
parent9a7bcacc275cc4aa4107598ab0305cdcac09d3e4
Reset grad attribute when called using del (#16525)

Summary:
del Tensor.grad set PyObject to nullptr
and Tensor.grad = None set PyObject to Py_None
Handling both the cases now
fixes ##16471
Pull Request resolved: https://github.com/pytorch/pytorch/pull/16525

Differential Revision: D14130800

Pulled By: soumith

fbshipit-source-id: ed85c38305bba94d5047311cb58e4e4cedd09832
test/test_autograd.py
torch/csrc/autograd/python_variable.cpp