The differences between torch.mul(A,B) and A*B

Hello!
Is there any possibility that when use A*B in pytorch, the operator * automatically produce dot product if A,B are not suitable size for matrix product, and produce matrix product otherwise???
I am so confuse since this change when I use sometimes

So! is torch.mul(A,B) the really matrix product operation and A*B is the dot product operation???

1 Like

Hi,

None of them is dot product. They both are element-wise multiplication.
Dot product/matrix multiplication is done with torch.mm or torch.mv or the @ symbol in python3.

4 Likes

Wow, I really did not know such difference. Here it is, torch.mm
Thx a lot!