fn
addbmm
→Tensoraddbmm(input: Tensor, batch1: Tensor, batch2: Tensor, beta: float = ..., alpha: float = ...)Batched matmul with reduction over the batch axis.
Computes . Useful for accumulating multiple parallel matrix products into a single output matrix (e.g. summing per-head attention contributions).
Parameters
inputTensorAccumulator of shape
(M, N).batch1TensorBatched left matrices of shape
(B, M, K).batch2TensorBatched right matrices of shape
(B, K, N).betafloatScalar multiplier on
input. Defaults to 1.0.alphafloatScalar multiplier on the batched matmul sum. Defaults to
1.0.Returns
TensorTensor of shape (M, N).
Notes
Mathematical definition:
Differs from baddbmm in that the batch dimension is reduced
away; baddbmm keeps the per-batch results.
Examples
>>> import lucid
>>> b1 = lucid.ones((3, 2, 4))
>>> b2 = lucid.ones((3, 4, 2))
>>> M = lucid.zeros((2, 2))
>>> lucid.addbmm(M, b1, b2)
Tensor([[12., 12.],
[12., 12.]])