Multiplication between two tensors is supported with the * operators. The result of the multiplication depends on the sizes of the tensors.

1D and 1D
Returns the dot product between the two tensors (scalar).
2D and 1D
Returns the matrix-vector operation between the two tensors (1D tensor).
2D and 2D
Returns the matrix-matrix operation between the two tensors (2D tensor).
4D and 2D
Returns a tensor product (2D tensor).
Sizes must be relevant for the corresponding operation.

A tensor might also be multiplied by a scalar. The scalar might be on the right or left of the operator.

Examples:

> M = torch.Tensor(2,2):fill(2)
> N = torch.Tensor(2,4):fill(3)
> x = torch.Tensor(2):fill(4)
> y = torch.Tensor(2):fill(5)
> = x*y -- dot product
40
> = M*x --- matrix-vector

 16
 16
[torch.Tensor of dimension 2]

> = M*N -- matrix-matrix

 12  12  12  12
 12  12  12  12
[torch.Tensor of dimension 2x4]