mindspore.ops.addbmm
- mindspore.ops.addbmm(input, batch1, batch2, *, beta=1, alpha=1)[source]
Applies batch matrix multiplication to batch1 and batch2, with a reduced add step and add input to the result.
The optional values alpha and beta are the matrix-matrix product between batch1 and batch2 and the scale factor for the added tensor input respectively. If beta is 0, then input will be ignored.
\[output = \beta input + \alpha (\sum_{i=0}^{b-1} {batch1_i @ batch2_i})\]- Parameters
- Keyword Arguments
- Returns
Tensor, has the same dtype as input.
- Raises
TypeError – If alpha or beta is not an int or float.
ValueError – If batch1, batch2 cannot apply batch matrix multiplication.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import numpy as np >>> from mindspore import Tensor, ops >>> m = np.ones((3, 3)).astype(np.float32) >>> arr1 = np.arange(24).astype(np.float32).reshape((2, 3, 4)) >>> arr2 = np.arange(24).astype(np.float32).reshape((2, 4, 3)) >>> a = Tensor(arr1) >>> b = Tensor(arr2) >>> c = Tensor(m) >>> output = ops.addbmm(c, a, b) >>> print(output) [[ 949. 1009. 1069.] [1285. 1377. 1469.] [1621. 1745. 1869.]]