fn
addmm
→Tensoraddmm(input: Tensor, mat1: Tensor, mat2: Tensor, beta: float = ..., alpha: float = ...)General matrix multiply with a scaled accumulator (GEMM).
Computes ,
the canonical BLAS-3 gemm operation. Useful for fused linear
layers: an output bias plus a weight multiplication in one call.
Parameters
inputTensorAccumulator of shape
(M, N) (or broadcastable to it).mat1TensorLeft matrix of shape
(M, K).mat2TensorRight matrix of shape
(K, N).betafloatScalar multiplier on
input. Defaults to 1.0.alphafloatScalar multiplier on
mat1 @ mat2. Defaults to 1.0.Returns
TensorTensor of shape (M, N).
Notes
Mathematical definition:
The inner dimension K must match between mat1 and mat2.
Standard dtype promotion applies; the matmul itself uses Accelerate
(CPU stream) or MLX (GPU stream).
Examples
>>> import lucid
>>> M = lucid.zeros((2, 2))
>>> a = lucid.tensor([[1., 2.], [3., 4.]])
>>> b = lucid.tensor([[5., 6.], [7., 8.]])
>>> lucid.addmm(M, a, b, beta=0.0, alpha=1.0)
Tensor([[19., 22.],
[43., 50.]])