Just to check I have understood you correctly… assuming you are calculating the gradient of some Loss function… your gradient calculation is this, right?
d_Loss/d_input = (output / input) * d_Loss/d_output
The easiest way to do this would be to implement a custom function rather than using a hook. See http://pytorch.org/docs/0.3.1/notes/extending.html 150