torch.addmm¶
- torch.addmm(input, mat1, mat2, *, beta=1, alpha=1, out=None) Tensor ¶
Performs a matrix multiplication of the matrices
mat1
andmat2
. The matrixinput
is added to the final result.If
mat1
is a tensor,mat2
is a tensor, theninput
must be broadcastable with a tensor andout
will be a tensor.alpha
andbeta
are scaling factors on matrix-vector product betweenmat1
andmat2
and the added matrixinput
respectively.If
beta
is 0, theninput
will be ignored, and nan and inf in it will not be propagated.For inputs of type FloatTensor or DoubleTensor, arguments
beta
andalpha
must be real numbers, otherwise they should be integers.This operation has support for arguments with sparse layouts. If
input
is sparse the result will have the same layout and ifout
is provided it must have the same layout asinput
.Warning
Sparse support is a beta feature and some layout(s)/dtype/device combinations may not be supported, or may not have autograd support. If you notice missing functionality please open a feature request.
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 ()
out (Tensor, optional) – the output tensor.
Example:
>>> M = torch.randn(2, 3) >>> mat1 = torch.randn(2, 3) >>> mat2 = torch.randn(3, 3) >>> torch.addmm(M, mat1, mat2) tensor([[-4.8716, 1.4671, -1.3746], [ 0.7573, -3.9555, -2.8681]])