If pytorch hasn’t complained about inplace operations, missing computation graphs or non-differentiable operations, then it is fairly safe to say that backpropagation works as expected.
Have you timed the various solutions?
I’d be interested to know which is fastest.