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

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


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


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