Solved by albanD in post #2 
              
              
                Hi, 
Unfortunately, you will only be able to get gradients using autograd if you use pytorch’s Tensor and operators to do all the computations. 
If you have an operation that you cannot do this way, you will need to provide the gradient formula yourself for that step. You can see how to extend the a…