mindspore.ops.baddbmm
- mindspore.ops.baddbmm(input, batch1, batch2, beta=1, alpha=1)[source]
Perform a batch matrix-matrix product of matrices in batch1 and batch2 , input is added to the final result.
Note
batch1 and batch2 must be 3-D tensors each containing the same number of matrices.
When batch1 is a
tensor and batch2 is a tensor, input must be broadcastable with tensor, and out will be a tensor.If beta is 0, then input will be ignored.
beta and alpha must be integers when inputs of type not FloatTensor.
- Parameters
input (Tensor) – The input tensor.
batch1 (Tensor) – The first batch of matrices to be multiplied.
batch2 (Tensor) – The second batch of matrices to be multiplied.
beta (Union[float, int], optional) – Scale factor for input. Default
1
.alpha (Union[float, int], optional) – Scale factor for ( batch1 @ batch2 ). Default
1
.
- Returns
Tensor
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore >>> input = mindspore.ops.ones((3, 3)) >>> batch1 = mindspore.tensor([[8., 7., 6.], [5., 4., 3.], [2., 1., 0.]]) >>> batch2 = mindspore.tensor([[5., 4., 3.], [2., 1., 0.], [8., 7., 6.]]) >>> output = mindspore.ops.baddbmm(input, batch1, batch2) >>> print(output) [[103. 82. 61.] [ 58. 46. 34.] [ 13. 10. 7.]]