# tensorplay.functional.baddbmm Source: https://www.tensorplay.cn/docs/generated/tensorplay.functional.baddbmm.html ```python tensorplay.functional.baddbmm(input, batch1, batch2, out_dtype=None, *, beta=1, alpha=1, out=None) → Tensor ``` Performs a batch matrix-matrix product of matrices in batch1 and batch2. input is added to the final result. batch1 and batch2 must be 3-D tensors each containing the same number of matrices. If batch1 is a $(b \times n \times m)$ tensor, batch2 is a $(b \times m \times p)$ tensor, then input must be [broadcastable](/docs/notes/broadcasting.html#broadcasting-semantics) with a $(b \times n \times p)$ tensor and out will be a $(b \times n \times p)$ tensor. Both alpha and beta mean the same as the scaling factors used in tensorplay.addbmm(). $$\text{out}_i = \beta\ \text{input}_i + \alpha\ (\text{batch1}_i \mathbin{@} \text{batch2}_i)$$ If beta is 0, then the content of input will be ignored, and nan and inf in it will not be propagated. For inputs of type FloatTensor or DoubleTensor, arguments beta and alpha must be real numbers, otherwise they should be integers. This operator supports [TensorFloat32](/docs/notes/numerical_accuracy.html#id6). On certain ROCm devices, when using float16 inputs this module will use [different precision](/docs/notes/numerical_accuracy.html#fp16-on-mi200) for backward. Parameters: - input ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor)) – the tensor to be added - batch1 ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor)) – the first batch of matrices to be multiplied - batch2 ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor)) – the second batch of matrices to be multiplied - out_dtype ([dtype](/docs/generated/tensorplay.DType.html#tensorplay.DType), optional) – the dtype of the output tensor, Supported only on CUDA and for tensorplay.float32 given tensorplay.float16/tensorplay.bfloat16 input dtypes Keyword Arguments: - beta (Number, optional) – multiplier for input ($\beta$) - alpha (Number, optional) – multiplier for $\text{batch1} \mathbin{@} \text{batch2}$ ($\alpha$) - out ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor), optional) – the output tensor. Example: ``` >>> M = tensorplay.randn(10, 3, 5) >>> batch1 = tensorplay.randn(10, 3, 4) >>> batch2 = tensorplay.randn(10, 4, 5) >>> tensorplay.baddbmm(M, batch1, batch2).size() tensorplay.Size([10, 3, 5]) ```