fused_matmul_bias¶
- paddle.incubate.nn.functional. fused_matmul_bias ( x, y, bias=None, transpose_x=False, transpose_y=False, name=None ) [source]
-
Applies matrix multiplication of two tensors and then bias addition if provided. This method requires CUDA version >= 11.6.
- Parameters
-
x (Tensor) – the first input Tensor to be multiplied.
y (Tensor) – the second input Tensor to be multiplied. Its rank must be 2.
bias (Tensor, optional) – the input bias Tensor. If it is None, no bias addition would be performed. Otherwise, the bias is added to the matrix multiplication result. Default: None.
transpose_x (bool, optional) – Whether to transpose \(x\) before multiplication. Default: False.
transpose_y (bool, optional) – Whether to transpose \(y\) before multiplication. Default: False.
name (str, optional) – For detailed information, please refer to Name . Usually name is no need to set and None by default.
- Returns
-
the output Tensor.
- Return type
-
Tensor
Examples
>>> >>> >>> import paddle >>> from paddle.incubate.nn.functional import fused_matmul_bias >>> paddle.set_device('gpu') >>> x = paddle.randn([3, 5]) >>> y = paddle.randn([4, 5]) >>> bias = paddle.randn([5]) >>> out = fused_matmul_bias(x, y, bias) >>> print(out.shape) [3, 5]