torch.addbmm#
- torch.addbmm(input, batch1, batch2, *, beta=1, alpha=1, out=None) Tensor#
Performs a batch matrix-matrix product of matrices stored in
batch1andbatch2, with a reduced add step (all matrix multiplications get accumulated along the first dimension).inputis added to the final result.batch1andbatch2must be 3-D tensors each containing the same number of matrices.If
batch1is a tensor,batch2is a tensor,inputmust be broadcastable with a tensor andoutwill be a tensor.If
betais 0, then the content ofinputwill be ignored, and nan and inf in it will not be propagated.For inputs of type FloatTensor or DoubleTensor, arguments
betaandalphamust be real numbers, otherwise they should be integers.This operator supports TensorFloat32.
On certain ROCm devices, when using float16 inputs this module will use different precision for backward.
- Parameters
- Keyword Arguments
beta (Number, optional) – multiplier for
input()alpha (Number, optional) – multiplier for batch1 @ batch2 ()
out (Tensor, optional) – the output tensor.
Example:
>>> M = torch.randn(3, 5) >>> batch1 = torch.randn(10, 3, 4) >>> batch2 = torch.randn(10, 4, 5) >>> torch.addbmm(M, batch1, batch2) tensor([[ 6.6311, 0.0503, 6.9768, -12.0362, -2.1653], [ -4.8185, -1.4255, -6.6760, 8.9453, 2.5743], [ -3.8202, 4.3691, 1.0943, -1.1109, 5.4730]])