mindspore.ops.addbmm

View Source On Gitee
mindspore.ops.addbmm(input, batch1, batch2, *, beta=1, alpha=1)[source]

Apply batch matrix multiplication to batch1 and batch2, with a reduced add step and add input to the result.

Note

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

  • When batch1 is a \((C, W, T)\) tensor and batch2 is a \((C, T, H)\) tensor, input must be broadcastable with \((W, H)\) tensor, and out will be a \((W, H)\) tensor.

  • If beta is 0, then input will be ignored.

\[output = \beta input + \alpha (\sum_{i=0}^{b-1} {batch1_i @ batch2_i})\]
Parameters
  • input (Tensor) – The input tensor.

  • batch1 (Tensor) – The first batch of tensor to be multiplied.

  • batch2 (Tensor) – The second batch of tensor to be multiplied.

Keyword Arguments
  • beta (Union[int, float], optional) – Scale factor for input. Default 1 .

  • alpha (Union[int, float], optional) – Scale factor for ( batch1 @ batch2 ). Default 1 .

Returns

Tensor

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> m = mindspore.ops.ones((3, 3))
>>> arr1 = mindspore.tensor([[8., 7., 6.], [5., 4., 3.], [2., 1., 0.]])
>>> arr2 = mindspore.tensor([[5., 4., 3.], [2., 1., 0.], [8., 7., 6.]])
>>> output = mindspore.ops.addbmm(m, arr1, arr2)
>>> print(output)
[[172. 136. 100.]
 [172. 136. 100.]
 [172. 136. 100.]]