Hello,
I need to create a tensor where entry i,j has value abs(i - j).
For now, the only solution I’ve found is by cycling each entry with for loop:
A = torch.zeros(1000, 2000)
for i in range(1000):
    for j in range(2000):
        A[i, j] = abs(i - j)

Unfortunately this solution is extremely slow.
I need this tensor to use it as mask of another tensor.
Someone has any alternative idea?