Hmmm, I’m not sure. You can double-check whether you implemented your gradient correctly using the gradcheck helper function.
http://pytorch.org/docs/master/notes/extending.html?highlight=gradcheck 696