Bmm

## Usage

torch_bmm(self, mat2)

## Arguments

self

(Tensor) the first batch of matrices to be multiplied

mat2

(Tensor) the second batch of matrices to be multiplied

## Note

This function does not broadcast . For broadcasting matrix products, see torch_matmul.

## bmm(input, mat2, out=NULL) -> Tensor

Performs a batch matrix-matrix product of matrices stored in input and mat2.

input and mat2 must be 3-D tensors each containing the same number of matrices.

If input is a $$(b \times n \times m)$$ tensor, mat2 is a $$(b \times m \times p)$$ tensor, out will be a $$(b \times n \times p)$$ tensor.

$$\mbox{out}_i = \mbox{input}_i \mathbin{@} \mbox{mat2}_i$$

## Examples

if (torch_is_installed()) {

input = torch_randn(c(10, 3, 4))
mat2 = torch_randn(c(10, 4, 5))
res = torch_bmm(input, mat2)
res
}
#> torch_tensor
#> (1,.,.) =
#>  -0.6668 -0.7527 -1.5229  1.4966  2.5872
#>   0.4386 -1.5797 -0.1287 -0.0617  0.5446
#>   0.0078  0.2735  1.2906 -0.2431 -1.9352
#>
#> (2,.,.) =
#>   0.6210 -3.7027  0.2292  0.1662 -2.1485
#>   0.7773  1.2278 -3.1853 -1.3366 -2.5568
#>   0.7020  2.1114 -2.6958 -1.5855 -1.9494
#>
#> (3,.,.) =
#>   2.4366  2.1640  2.4777 -4.3598  2.3854
#>  -0.9496 -1.4892 -2.0137  3.2990 -0.7943
#>   2.1103 -0.3613 -0.1985  0.2844  2.0784
#>
#> (4,.,.) =
#>   0.5756 -0.2154  0.2895 -0.3379 -0.7951
#>   1.7087 -0.5048  0.4555  0.6827  0.8221
#>  -0.6560  2.1476 -0.4176  1.1168 -0.8709
#>
#> (5,.,.) =
#>  -5.3473 -1.3028  1.3888  0.6719  2.5425
#>  -1.9673 -0.6747  1.1727  0.1568  0.8675
#>   1.5578  2.4624 -2.5518  0.0249  0.8560
#>
#> (6,.,.) =
#>  -0.4996 -0.4467 -0.3228 -0.5470  0.6067
#>  -0.4206  1.2013 -0.9708 -2.0033 -1.1624
#>   0.3929  0.3060  1.5993 -1.8301  0.4189
#>
#> ... [the output was truncated (use n=-1 to disable)]
#> [ CPUFloatType{10,3,5} ]