From 6108480567a92b20588726c58fa9b2d945cbe999 Mon Sep 17 00:00:00 2001 From: zhanganduo Date: Thu, 7 Dec 2023 19:49:38 +0800 Subject: [PATCH 1/6] add docs --- .../api/paddle/incubate/nn/FusedLinear_cn.rst | 45 +++++++++++++++++++ .../nn/functional/fused_matmul_bias_cn.rst | 28 ++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 docs/api/paddle/incubate/nn/FusedLinear_cn.rst create mode 100644 docs/api/paddle/incubate/nn/functional/fused_matmul_bias_cn.rst diff --git a/docs/api/paddle/incubate/nn/FusedLinear_cn.rst b/docs/api/paddle/incubate/nn/FusedLinear_cn.rst new file mode 100644 index 00000000000..f913caddc57 --- /dev/null +++ b/docs/api/paddle/incubate/nn/FusedLinear_cn.rst @@ -0,0 +1,45 @@ +.. _cn_api_paddle_incubate_nn_FusedLinear: + +FusedLinear +------------------------------- + +.. py:class:: paddle.incubate.nn.FusedLinear(in_features, out_features, weight_attr=None, bias_attr=None, transpose_weight=False, name=None) + +线性层仅接受一个多维张量作为输入,其形状为 :math:`[batch\_size, *, in\_features]`,其中 :math:`*` 表示任意数量的额外维度。 + +它将输入张量与权重(形状为 :math:`[in\_features, out\_features]` 的二维张量)相乘,产生形状为 :math:`[batch\_size, *, out\_features]` 的输出张量。 + +如果 :math:`bias\_attr` 不为 False,则将创建偏置(形状为 :math:`[out\_features]` 的一维张量)并加到输出上。 + +参数 +:::::::::::: + - **in_features** (int) - 输入单元的数量。 + - **out_features** (int) - 输出单元的数量。 + - **weight_attr** (ParamAttr,可选) - 指定权重参数属性的对象。默认值:``None``,表示使用默认的权重参数属性,即使用 0 进行初始化。具体用法请参见 :ref:`cn_api_paddle_ParamAttr` 。 + - **transpose_weight** (bool) - 在乘法前是否转置 `weight` 张量。 + - **bias_attr** (ParamAttr|bool,可选) - 指定偏置参数属性的对象。如果该参数值是 ``ParamAttr``,则使用 ``ParamAttr``。如果该参数为 ``bool`` 类型,只支持为 ``False``,表示没有偏置参数。默认值为 None,表示使用默认的偏置参数属性。具体用法请参见 :ref:`cn_api_paddle_ParamAttr` 。 + - **name** (str,可选) - 通常用户无需设置此参数。有关详细信息,请参阅 :ref:`api_guide_Name`。 + +属性 +:::::::::::: + - **weight** (Parameter) - 本层的可学习权重。 + - **bias** (Parameter) - 本层的可学习偏置。 + +形状 +:::::::::::: + - 输入:形状为 :math:`[batch\_size, *, in\_features]` 的多维张量。 + - 输出:形状为 :math:`[batch\_size, *, out\_features]` 的多维张量。 + +代码示例 +::::::::: + +COPY-FROM: paddle.incubate.nn.FusedLinear + +forward(input) +:::::::::::: +定义每次调用时执行的计算。应由所有子类覆盖。 + +参数 +:::::::::::: + - **inputs** (tuple) - 解压缩的元组参数。 + - **kwargs** (dict) - 解压缩的字典参数。 diff --git a/docs/api/paddle/incubate/nn/functional/fused_matmul_bias_cn.rst b/docs/api/paddle/incubate/nn/functional/fused_matmul_bias_cn.rst new file mode 100644 index 00000000000..a9641621793 --- /dev/null +++ b/docs/api/paddle/incubate/nn/functional/fused_matmul_bias_cn.rst @@ -0,0 +1,28 @@ +.. _cn_api_paddle_incubate_nn_functional_fused_matmul_bias: + +fused_matmul_bias +------------------------------- + +.. py:function:: paddle.incubate.nn.functional.fused_matmul_bias(x, y, bias=None, transpose_x=False, transpose_y=False, name=None) + +应用两个张量的矩阵乘法,然后如果提供了偏置,进行偏置加法。 + +此方法要求 CUDA 版本不低于 11.6。 + +参数 +:::::::::::: + - **x** (Tensor) - 第一个输入 ``Tensor``,被乘 ``Tensor``。 + - **y** (Tensor) - 第二个输入 ``Tensor``,被乘 ``Tensor``。其秩必须为 2。 + - **bias** (Tensor,可选) - 输入的偏置。如果为 None,则不执行偏置加法。否则,偏置将被加到矩阵乘法结果上。默认:None。 + - **transpose_x** (bool,可选) - 是否在乘法前转置 :math:`x`。默认:False。 + - **transpose_y** (bool,可选) - 是否在乘法前转置 :math:`y`。默认:False。 + - **name** (str,可选) - 具体信息请参阅 :ref:`api_guide_Name`。通常无需设置名称,默认为 None。 + +返回 +:::::::::::: +输出 ``Tensor` + +代码示例 +:::::::::::: + +COPY-FROM: paddle.incubate.nn.functional.fused_matmul_bias From 85f0508eadba638ad7eb101a655efd111d738b80 Mon Sep 17 00:00:00 2001 From: Android zhang <53324261+zade23@users.noreply.github.com> Date: Mon, 11 Dec 2023 17:37:33 +0800 Subject: [PATCH 2/6] Update docs/api/paddle/incubate/nn/functional/fused_matmul_bias_cn.rst Co-authored-by: zachary sun <70642955+sunzhongkai588@users.noreply.github.com> --- docs/api/paddle/incubate/nn/functional/fused_matmul_bias_cn.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/paddle/incubate/nn/functional/fused_matmul_bias_cn.rst b/docs/api/paddle/incubate/nn/functional/fused_matmul_bias_cn.rst index a9641621793..f5b6d20b9bb 100644 --- a/docs/api/paddle/incubate/nn/functional/fused_matmul_bias_cn.rst +++ b/docs/api/paddle/incubate/nn/functional/fused_matmul_bias_cn.rst @@ -20,7 +20,7 @@ fused_matmul_bias 返回 :::::::::::: -输出 ``Tensor` +输出 ``Tensor`` 代码示例 :::::::::::: From afbfd15d2f76d0140ef0022838ac6866caa96dda Mon Sep 17 00:00:00 2001 From: Android zhang <53324261+zade23@users.noreply.github.com> Date: Tue, 12 Dec 2023 16:21:26 +0800 Subject: [PATCH 3/6] Update FusedLinear_cn.rst --- .../api/paddle/incubate/nn/FusedLinear_cn.rst | 50 +++++++++---------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/docs/api/paddle/incubate/nn/FusedLinear_cn.rst b/docs/api/paddle/incubate/nn/FusedLinear_cn.rst index f913caddc57..6a93af00aa4 100644 --- a/docs/api/paddle/incubate/nn/FusedLinear_cn.rst +++ b/docs/api/paddle/incubate/nn/FusedLinear_cn.rst @@ -5,41 +5,39 @@ FusedLinear .. py:class:: paddle.incubate.nn.FusedLinear(in_features, out_features, weight_attr=None, bias_attr=None, transpose_weight=False, name=None) -线性层仅接受一个多维张量作为输入,其形状为 :math:`[batch\_size, *, in\_features]`,其中 :math:`*` 表示任意数量的额外维度。 - -它将输入张量与权重(形状为 :math:`[in\_features, out\_features]` 的二维张量)相乘,产生形状为 :math:`[batch\_size, *, out\_features]` 的输出张量。 - -如果 :math:`bias\_attr` 不为 False,则将创建偏置(形状为 :math:`[out\_features]` 的一维张量)并加到输出上。 +Linear 层只接受一个 Tensor 作为输入,形状为 :math:`[batch\_size, *, in\_features]`,其中 :math:`*` 表示可以为任意个额外的维度。 +该层可以计算输入 Tensor 与权重矩阵 :math:`W` 的乘积,然后生成形状为 :math:`[batch\_size, *, out\_features]` 的输出 Tensor。 +如果 :math:`bias\_attr` 不是 False,则将创建一个偏置参数并将其添加到输出中。 参数 :::::::::::: - - **in_features** (int) - 输入单元的数量。 - - **out_features** (int) - 输出单元的数量。 - - **weight_attr** (ParamAttr,可选) - 指定权重参数属性的对象。默认值:``None``,表示使用默认的权重参数属性,即使用 0 进行初始化。具体用法请参见 :ref:`cn_api_paddle_ParamAttr` 。 - - **transpose_weight** (bool) - 在乘法前是否转置 `weight` 张量。 - - **bias_attr** (ParamAttr|bool,可选) - 指定偏置参数属性的对象。如果该参数值是 ``ParamAttr``,则使用 ``ParamAttr``。如果该参数为 ``bool`` 类型,只支持为 ``False``,表示没有偏置参数。默认值为 None,表示使用默认的偏置参数属性。具体用法请参见 :ref:`cn_api_paddle_ParamAttr` 。 - - **name** (str,可选) - 通常用户无需设置此参数。有关详细信息,请参阅 :ref:`api_guide_Name`。 +- **in_features** (int) – 线性变换层输入单元的数目。 +- **out_features** (int) – 线性变换层输出单元的数目。 +- **weight_attr** (ParamAttr,可选) - 指定权重参数的属性。默认值为 None,权重将初始化为零。具体用法请参见 :ref:`cn_api_paddle_ParamAttr` 。 +- **transpose_weight** (bool) - 在乘积运算前是否转置 `weight` 张量。 +- **bias_attr** (ParamAttr|bool,可选) – 指定偏置参数的属性。:math:`bias\_attr` 为 bool 类型且设置为 False 时,表示不会为该层添加偏置。:math:`bias\_attr` 如果设置为 True 或者 None,则表示使用默认的偏置参数属性,将偏置参数初始化为 0。具体用法请参见 :ref:`cn_api_paddle_ParamAttr`。默认值为 None。 +- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。 属性 -:::::::::::: - - **weight** (Parameter) - 本层的可学习权重。 - - **bias** (Parameter) - 本层的可学习偏置。 +::::::::: + +weight +''''''''' + +本层的可学习参数,类型为 ``Parameter`` 。 + +bias +''''''''' + +本层的可学习偏置,类型为 ``Parameter`` 。 形状 -:::::::::::: - - 输入:形状为 :math:`[batch\_size, *, in\_features]` 的多维张量。 - - 输出:形状为 :math:`[batch\_size, *, out\_features]` 的多维张量。 +::::::::: + +- 输入:形状为 :math:`[batch\_size, *, in\_features]` 的多维 Tensor。 +- 输出:形状为 :math:`[batch\_size, *, out\_features]` 的多维 Tensor。 代码示例 ::::::::: COPY-FROM: paddle.incubate.nn.FusedLinear - -forward(input) -:::::::::::: -定义每次调用时执行的计算。应由所有子类覆盖。 - -参数 -:::::::::::: - - **inputs** (tuple) - 解压缩的元组参数。 - - **kwargs** (dict) - 解压缩的字典参数。 From 0720218e869031b714a86cf6b15f700cc30f1576 Mon Sep 17 00:00:00 2001 From: Android zhang <53324261+zade23@users.noreply.github.com> Date: Tue, 12 Dec 2023 16:21:42 +0800 Subject: [PATCH 4/6] Update fused_matmul_bias_cn.rst --- .../nn/functional/fused_matmul_bias_cn.rst | 51 ++++++++++++------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/docs/api/paddle/incubate/nn/functional/fused_matmul_bias_cn.rst b/docs/api/paddle/incubate/nn/functional/fused_matmul_bias_cn.rst index f5b6d20b9bb..6a93af00aa4 100644 --- a/docs/api/paddle/incubate/nn/functional/fused_matmul_bias_cn.rst +++ b/docs/api/paddle/incubate/nn/functional/fused_matmul_bias_cn.rst @@ -1,28 +1,43 @@ -.. _cn_api_paddle_incubate_nn_functional_fused_matmul_bias: +.. _cn_api_paddle_incubate_nn_FusedLinear: -fused_matmul_bias +FusedLinear ------------------------------- -.. py:function:: paddle.incubate.nn.functional.fused_matmul_bias(x, y, bias=None, transpose_x=False, transpose_y=False, name=None) +.. py:class:: paddle.incubate.nn.FusedLinear(in_features, out_features, weight_attr=None, bias_attr=None, transpose_weight=False, name=None) -应用两个张量的矩阵乘法,然后如果提供了偏置,进行偏置加法。 - -此方法要求 CUDA 版本不低于 11.6。 +Linear 层只接受一个 Tensor 作为输入,形状为 :math:`[batch\_size, *, in\_features]`,其中 :math:`*` 表示可以为任意个额外的维度。 +该层可以计算输入 Tensor 与权重矩阵 :math:`W` 的乘积,然后生成形状为 :math:`[batch\_size, *, out\_features]` 的输出 Tensor。 +如果 :math:`bias\_attr` 不是 False,则将创建一个偏置参数并将其添加到输出中。 参数 :::::::::::: - - **x** (Tensor) - 第一个输入 ``Tensor``,被乘 ``Tensor``。 - - **y** (Tensor) - 第二个输入 ``Tensor``,被乘 ``Tensor``。其秩必须为 2。 - - **bias** (Tensor,可选) - 输入的偏置。如果为 None,则不执行偏置加法。否则,偏置将被加到矩阵乘法结果上。默认:None。 - - **transpose_x** (bool,可选) - 是否在乘法前转置 :math:`x`。默认:False。 - - **transpose_y** (bool,可选) - 是否在乘法前转置 :math:`y`。默认:False。 - - **name** (str,可选) - 具体信息请参阅 :ref:`api_guide_Name`。通常无需设置名称,默认为 None。 - -返回 -:::::::::::: -输出 ``Tensor`` +- **in_features** (int) – 线性变换层输入单元的数目。 +- **out_features** (int) – 线性变换层输出单元的数目。 +- **weight_attr** (ParamAttr,可选) - 指定权重参数的属性。默认值为 None,权重将初始化为零。具体用法请参见 :ref:`cn_api_paddle_ParamAttr` 。 +- **transpose_weight** (bool) - 在乘积运算前是否转置 `weight` 张量。 +- **bias_attr** (ParamAttr|bool,可选) – 指定偏置参数的属性。:math:`bias\_attr` 为 bool 类型且设置为 False 时,表示不会为该层添加偏置。:math:`bias\_attr` 如果设置为 True 或者 None,则表示使用默认的偏置参数属性,将偏置参数初始化为 0。具体用法请参见 :ref:`cn_api_paddle_ParamAttr`。默认值为 None。 +- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。 + +属性 +::::::::: + +weight +''''''''' + +本层的可学习参数,类型为 ``Parameter`` 。 + +bias +''''''''' + +本层的可学习偏置,类型为 ``Parameter`` 。 + +形状 +::::::::: + +- 输入:形状为 :math:`[batch\_size, *, in\_features]` 的多维 Tensor。 +- 输出:形状为 :math:`[batch\_size, *, out\_features]` 的多维 Tensor。 代码示例 -:::::::::::: +::::::::: -COPY-FROM: paddle.incubate.nn.functional.fused_matmul_bias +COPY-FROM: paddle.incubate.nn.FusedLinear From 125fe2da9f517706786fde560ccc0ab4d3a35af1 Mon Sep 17 00:00:00 2001 From: Android zhang <53324261+zade23@users.noreply.github.com> Date: Tue, 12 Dec 2023 16:22:27 +0800 Subject: [PATCH 5/6] Update fused_matmul_bias_cn.rst --- .../nn/functional/fused_matmul_bias_cn.rst | 47 +++++++------------ 1 file changed, 16 insertions(+), 31 deletions(-) diff --git a/docs/api/paddle/incubate/nn/functional/fused_matmul_bias_cn.rst b/docs/api/paddle/incubate/nn/functional/fused_matmul_bias_cn.rst index 6a93af00aa4..1cb6b4a044d 100644 --- a/docs/api/paddle/incubate/nn/functional/fused_matmul_bias_cn.rst +++ b/docs/api/paddle/incubate/nn/functional/fused_matmul_bias_cn.rst @@ -1,43 +1,28 @@ -.. _cn_api_paddle_incubate_nn_FusedLinear: +.. _cn_api_paddle_incubate_nn_functional_fused_matmul_bias: -FusedLinear +fused_matmul_bias ------------------------------- -.. py:class:: paddle.incubate.nn.FusedLinear(in_features, out_features, weight_attr=None, bias_attr=None, transpose_weight=False, name=None) +.. py:function:: paddle.incubate.nn.functional.fused_matmul_bias(x, y, bias=None, transpose_x=False, transpose_y=False, name=None) -Linear 层只接受一个 Tensor 作为输入,形状为 :math:`[batch\_size, *, in\_features]`,其中 :math:`*` 表示可以为任意个额外的维度。 -该层可以计算输入 Tensor 与权重矩阵 :math:`W` 的乘积,然后生成形状为 :math:`[batch\_size, *, out\_features]` 的输出 Tensor。 -如果 :math:`bias\_attr` 不是 False,则将创建一个偏置参数并将其添加到输出中。 +应用两个张量的矩阵乘法,然后如果提供了偏置,进行偏置加法。 + +此方法要求 CUDA 版本不低于 11.6。 参数 :::::::::::: -- **in_features** (int) – 线性变换层输入单元的数目。 -- **out_features** (int) – 线性变换层输出单元的数目。 -- **weight_attr** (ParamAttr,可选) - 指定权重参数的属性。默认值为 None,权重将初始化为零。具体用法请参见 :ref:`cn_api_paddle_ParamAttr` 。 -- **transpose_weight** (bool) - 在乘积运算前是否转置 `weight` 张量。 -- **bias_attr** (ParamAttr|bool,可选) – 指定偏置参数的属性。:math:`bias\_attr` 为 bool 类型且设置为 False 时,表示不会为该层添加偏置。:math:`bias\_attr` 如果设置为 True 或者 None,则表示使用默认的偏置参数属性,将偏置参数初始化为 0。具体用法请参见 :ref:`cn_api_paddle_ParamAttr`。默认值为 None。 +- **x** (Tensor) - 第一个输入 ``Tensor``,被乘 ``Tensor``。 +- **y** (Tensor) - 第二个输入 ``Tensor``,被乘 ``Tensor``。其秩必须为 2。 +- **bias** (Tensor,可选) - 输入的偏置。如果为 None,则不执行偏置加法。否则,偏置将被加到矩阵乘法结果上。默认:None。 +- **transpose_x** (bool,可选) - 是否在乘积运算前转置 :math:`x`。默认:False。 +- **transpose_y** (bool,可选) - 是否在乘积运算前转置 :math:`y`。默认:False。 - **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。 -属性 -::::::::: - -weight -''''''''' - -本层的可学习参数,类型为 ``Parameter`` 。 - -bias -''''''''' - -本层的可学习偏置,类型为 ``Parameter`` 。 - -形状 -::::::::: - -- 输入:形状为 :math:`[batch\_size, *, in\_features]` 的多维 Tensor。 -- 输出:形状为 :math:`[batch\_size, *, out\_features]` 的多维 Tensor。 +返回 +:::::::::::: +输出 ``Tensor` 代码示例 -::::::::: +:::::::::::: -COPY-FROM: paddle.incubate.nn.FusedLinear +COPY-FROM: paddle.incubate.nn.functional.fused_matmul_bias From 7ffa072999e27b1df40261c52bd9ee746abf14a4 Mon Sep 17 00:00:00 2001 From: Android zhang <53324261+zade23@users.noreply.github.com> Date: Tue, 19 Dec 2023 20:34:15 +0800 Subject: [PATCH 6/6] Update FusedLinear_cn.rst --- docs/api/paddle/incubate/nn/FusedLinear_cn.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/api/paddle/incubate/nn/FusedLinear_cn.rst b/docs/api/paddle/incubate/nn/FusedLinear_cn.rst index 6a93af00aa4..c188ea2aaf7 100644 --- a/docs/api/paddle/incubate/nn/FusedLinear_cn.rst +++ b/docs/api/paddle/incubate/nn/FusedLinear_cn.rst @@ -5,9 +5,9 @@ FusedLinear .. py:class:: paddle.incubate.nn.FusedLinear(in_features, out_features, weight_attr=None, bias_attr=None, transpose_weight=False, name=None) -Linear 层只接受一个 Tensor 作为输入,形状为 :math:`[batch\_size, *, in\_features]`,其中 :math:`*` 表示可以为任意个额外的维度。 +FusedLinear 层只接受一个 Tensor 作为输入,形状为 :math:`[batch\_size, *, in\_features]`,其中 :math:`*` 表示可以为任意个额外的维度。 该层可以计算输入 Tensor 与权重矩阵 :math:`W` 的乘积,然后生成形状为 :math:`[batch\_size, *, out\_features]` 的输出 Tensor。 -如果 :math:`bias\_attr` 不是 False,则将创建一个偏置参数并将其添加到输出中。 +如果 :math:`bias\_attr` 不是 False,则将创建一个偏置参数并将其添加到输出中。此方法要求 CUDA 版本不低于 11.6。 参数 ::::::::::::