What is the gradient of pytorch floor() gradient method?
I am looking to use floor() method in one of my models. I would like to understand what pytorch does with its gradient propagation since as such floor is a discontinuous method.

If there is no gradient defined, I could override the backward method to define my own gradient as necessary but I would like to understand what the default behavior is and the corresponding source code if possible.

import torch

x = torch.rand(20, requires_grad=True)
y = 20*x
z = y.floor().sum()
z.backward()


x.grad returns zeros.

z has a grad_fn=

So FloorBackward is the gradient method. But there is no reference to the source code of FloorBackward in pytorch repository.

As the floor function is piece wise constant. This means the gradient must be zero almost everywhere.



While the code doesn't say anything about it, I expect that the gradient is set to a constant zero everywhere.
