fn

mm

Tensor
mm(input: Tensor, other: Tensor | Scalar)
source

Strict 2-D matrix multiplication.

Computes the product of two 2-D tensors of shapes (n, k) and (k, m). No broadcasting is performed; both operands must be exactly 2-D. For broadcasting or batched semantics use matmul / bmm.

Parameters

inputTensor
Left matrix of shape (n, k).
otherTensor or scalar
Right matrix of shape (k, m). The inner dimension must match input.

Returns

Tensor

Matrix product of shape (n, m).

Notes

Mathematical definition:

Cij=r=1kAirBrj\mathbf{C}_{ij} = \sum_{r=1}^{k} \mathbf{A}_{ir}\,\mathbf{B}_{rj}

Autograd mirrors matmul but without any batch handling. Use this function when the rank assumption can be guaranteed for clearer error messages and slightly leaner dispatch.

Examples

>>> import lucid
>>> a = lucid.tensor([[1.0, 2.0]])
>>> b = lucid.tensor([[3.0], [4.0]])
>>> lucid.mm(a, b)
Tensor([[11.]])