baddbmm

paddle. baddbmm ( input: Tensor, x: Tensor, y: Tensor, beta: float = 1.0, alpha: float = 1.0, name: str | None = None ) Tensor [source]

baddbmm

Perform batch matrix multiplication for input $x$ and $y$. $input$ is added to the final result. The equation is:

\[Out = alpha * x * y + beta * input\]

$Input$, $x$ and $y$ can carry the LoD (Level of Details) information, or not. But the output only shares the LoD information with input $input$.

Parameters
  • input (Tensor) – The input Tensor to be added to the final result.

  • x (Tensor) – The first input Tensor for batch matrix multiplication.

  • y (Tensor) – The second input Tensor for batch matrix multiplication.

  • beta (float, optional) – Coefficient of $input$, default is 1.

  • alpha (float, optional) – Coefficient of $x*y$, default is 1.

  • name (str|None, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.

Returns

The output Tensor of baddbmm.

Return type

Tensor

Examples

>>> import paddle

>>> x = paddle.ones([2, 2, 2])
>>> y = paddle.ones([2, 2, 2])
>>> input = paddle.ones([2, 2, 2])

>>> out = paddle.baddbmm(input=input, x=x, y=y, beta=0.5, alpha=5.0)

>>> out
Tensor(shape=[2, 2, 2], dtype=float32, place=Place(cpu), stop_gradient=True,
[[[10.50000000, 10.50000000],
  [10.50000000, 10.50000000]],
 [[10.50000000, 10.50000000],
  [10.50000000, 10.50000000]]])