Compute difference of each element in a tensor with each other

I think broadcasting might work:

x = torch.arange(10).view(-1, 1).expand(10, 2)
x[:, 0] - x[:, 1].view(-1, 1)
1 Like