Thanks for your reply. But
x = torch.tensor([-0.6, -0.5, -0.4, 0.4, 0.5, 0.6])
y = torch.round(x + 1e-6) # [-1., -0., -0., 0., 1., 1.]
y = torch.floor(x + 1e-6) # [-1., -1., -1., 0., 0., 0.]
y = torch.ceil(x + 1e-6) # [-0., -0., -0., 1., 1., 1.]
All of them are not [-1., -1., -0., 0., 1., 1.]
.
element-wise operation won’t have such a bad overhead
I tried x = torch.sign(x) * torch.floor(torch.abs(x) + 0.5)
. It is indeed faster (a bit).
Thank you.