torch.bmm(batch1batch2out=None) → Tensor

Performs a batch matrix-matrix product of matrices stored in batch1 and batch2.

batch1 and batch2 must be 3-D tensors each containing the same number of matrices.

If batch1 is a ensor.

outi=batch1i@batch2i

Note

This function does not broadcast. For broadcasting matrix products, see torch.matmul().

Parameters:
  • batch1 (Tensor) – the first batch of matrices to be multiplied
  • batch2 (Tensor) – the second batch of matrices to be multiplied
  • out (Tensoroptional) – the output tensor

Example:

>>> batch1 = torch.randn(10, 3, 4)
>>> batch2 = torch.randn(10, 4, 5)
>>> res = torch.bmm(batch1, batch2)
>>> res.size()
torch.Size([10, 3, 5])