paddle.incubate.nn.functional. fused_linear ( x, weight, bias=None, transpose_weight=False, name=None ) [source]

Fully-connected linear transformation operator. This method requires CUDA version >= 11.6.

  • x (Tensor) – the input Tensor to be multiplied.

  • weight (Tensor) – the weight Tensor to be multiplied. Its rank must be 2.

  • bias (Tensor|None) – the input bias Tensor. If it is None, no bias addition would be performed. Otherwise, the bias is added to the matrix multiplication result.

  • transpose_weight (bool) – Whether to transpose \(weight\) before multiplication.

  • name (str|None) – For detailed information, please refer to Name . Usually name is no need to set and None by default.


the output Tensor.

Return type



# required: gpu
import paddle
from paddle.incubate.nn.functional import fused_linear

x = paddle.randn([3, 4])
weight = paddle.randn([4, 5])
bias = paddle.randn([5])
out = fused_linear(x, weight, bias)
print(out.shape) # [3, 5]