Can the type of a gradient only be a floating type in new versions of Pytorch?

When I return a Long gradient, Pytorch 1.5 complains with this error that it should be a floating type.

However when I cast this to float gradient in Pytorch 1.2, it complains that expected Long gradient but received float.

Has behavior changed over versions?


Gradients for Long Tensors were never really supported. And were raising errors if used at random places.
We now unified this and properly raise an error when they are created (as you cannot use them anyway) so that the user can easily pinpoint the issue.

1 Like