If I have a tensor [1,2,3,4], how can I get tensor [0, 1, 1, 2, 2, 2, 3, 3, 3, 3] as fast as possible?
A for-loop is very slow, but I haven’t find any relevant Pytorch API.
Can anyone provide a good way?