Solved by albanD in post #2 
              
              
                Hi, 
You can definitely use register_hook to know when gradients are computed for a Tensor (it is executed just before the gradient is accumulated and the new value is passed as an argument). 
But I don’t think you will be able to have a callback every time a Tensor is modified inplace