hi,
I have two tensor a, b with the shape (batch_size,seq_len,dim)
the first operation is M=torch.bmm(a,b.transpose(1,2))  it works pretty fast.
and the second operation output the same result, but works pretty slowly:
a=a.unsqueeze(2)
b=b.unsqueeze(1)
N=(a*b).sum(-1)
my question is why does bmm work so fast , is it because the cuda optimize for matrix multiplication?
and the second question is is there accelerated way to do subtraction operation like bmm? the subtraction operation is like below:
a=a.unsqueeze(2)
b=b.unsqueeze(1)
N=(a-b).sum(-1)
Thank you!