Solved by ptrblck in post #2 
              
              
                The round operation would kill the gradient (almost) everywhere, so it’s indeed not very useful for training as seen here: 
x = torch.randn(10, requires_grad=True)
y = torch.round(x)
y.mean().backward()
print(x.grad)
> tensor([0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])

You could try to implement this…