I am using a nested for loop to get outputs from my model for 1000 images compared with themselves. model takes 2 images and outputs a scaler. A is a tensor of size (1000,3,128,128) and B=A. But, it is taking a long time to get the output.
out=[]
for i in A:
        temp=[]
        for j in B:
            temp.append(model(i,j))
        out.append(temp)

Final shape of out is (1000,1000). Above code just gives the overall idea of my task and 1000 is arbitrary.
I am actually using batch of size 8 instead of 1 (as above) to speed up the process. But, this is still taking a lot of time. Can anyone help me with this? I also want to know if there is a method to avoid duplicate comparisons as out matrix is symmetric.