torch.mm
- torch.mm(input, mat2, *, out=None) → Tensor
Performs a matrix multiplication of the matrices
inputand.
Performs a matrix multiplication of the matrices input and .
If input is a tensor, mat2 is a
tensor, out will be a tensor.
Supports strided and sparse 2-D tensors as inputs, autograd with respect to strided inputs.
This operation has support for arguments with sparse layouts.
If out is provided its layout will be used. Otherwise, the result
layout will be deduced from that of input.
This operator supports TensorFloat32.
On certain ROCm devices, when using float16 inputs this module will use different precision for backward.
Example:
>>> mat1 = torch.randn(2, 3)
>>> mat2 = torch.randn(3, 3)
>>> torch.mm(mat1, mat2)
tensor([[ 0.4851, 0.5037, -0.3633],
[-0.0760, -3.6705, 2.4784]])
input (Tensor) – the first matrix to be matrix multiplied
mat2 (Tensor) – the second matrix to be matrix multiplied
out_dtype (dtype) – the dtype of the output tensor.
On CUDA and XPU, only torch.float32 is supported given
torch.float16/torch.bfloat16 input dtypes. Other backends
(including out-of-tree accelerators) may support additional
input/output dtype combinations.
out (Tensor, optional) – the output tensor.