I think torch.where 163 on master will solve your problem.
Otherwise, you could try something like:
mask = x[x > 0.0].float()
x * mask + x[x <= 0.0].float()

but I’m not sure if that’s differentiable.