Solved by ptrblck in post #2 
              
              
                I’m not sure if I understand it correctly, but I think this will do it: 
a = torch.randn(5, 3)
b = torch.randn(5, 3)

res = a.unsqueeze(1) - b
# res[i] corresponds to (a[i] - b)