mindspore.ops.addmm
- mindspore.ops.addmm(input, mat1, mat2, *, beta=1, alpha=1)[source]
Multiplies matrix mat1 and matrix mat2. The matrix input is added to the final result.
\[output = \beta input + \alpha (mat1 @ mat2)\]- Parameters
- Keyword Arguments
- Returns
Tensor, has the same dtype as input.
- Raises
ValueError – If mat1, mat2 cannot apply matrix multiplication.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> m = np.ones((3, 3)).astype(np.float32) >>> arr1 = np.arange(12).astype(np.float32).reshape((3, 4)) >>> arr2 = np.arange(12).astype(np.float32).reshape((4, 3)) >>> a = Tensor(arr1) >>> b = Tensor(arr2) >>> c = Tensor(m) >>> output = ops.addmm(c, a, b) >>> print(output) [[ 43. 49. 55.] [115. 137. 159.] [187. 225. 263.]]