How to use the tensor maltiply to get a scalar? dimension compatible?

w = torch.randn(1,2)
c = torch.randn(2,1)

f1 = torch.mul(c,w)
f2 = torch.mul(w,c)
print(f1,f2)

Blockquote
tensor([[ 3.7364, -1.2104],
[ 1.6452, -0.5330]])
tensor([[ 3.7364, -1.2104],
[ 1.6452, -0.5330]])
Blockquote

why f1 and f2 are the same?
is the matrix dimension compatible?

Probably you would like to use a matrix multiplication to get a [1, 1] tensor:

torch.matmul(w, c)

torch,mul multiplies each element of the first tensor with each element of the second using broadcasting if necessary.