The issue is that the output of torch.arange has dtype torch.int64, while torch.randn and torch.zeros give output of dtype torch.float32 thus the scatter works.
Screenshot from 2020-09-12 20-37-01733×201 26.9 KB