Skip to content

[API compatibility] add docs for alias func #7388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/api/paddle/Tensor_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1149,9 +1149,13 @@ exponential_(lam=1.0, name=None)

f(x) = \lambda e^{-\lambda x}

.. note::
别名支持: 参数名 ``lambd`` 可替代 ``lam``,如 ``lambd=1.0`` 等价于 ``lam=1.0``。

参数:
- **x** (Tensor) - 输入 Tensor,数据类型为 float32/float64。
- **lam** (float) - 指数分布的 :math:`\lambda` 参数。
- **lambd** - ``lam`` 的别名,行为完全一致。
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。


Expand Down
5 changes: 5 additions & 0 deletions docs/api/paddle/bitwise_or_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,16 @@ bitwise_or

.. _Tensor 介绍: ../../guides/beginner/tensor_cn.html#id7

.. note::
别名支持: 参数名 ``input`` 可替代 ``x``和 ``other`` 可替代 ``y``,如 ``input=tensor_x`` 等价于 ``x=tensor_x``, ``other=tensor_y`` 等价于 ``y=tensor_y``。

参数
::::::::::::

- **x** (Tensor)- 输入的 N-D `Tensor`,数据类型为:bool,uint8,int8,int16,int32,int64。
- **input** - ``x`` 的别名,行为完全一致。
- **y** (Tensor)- 输入的 N-D `Tensor`,数据类型为:bool,uint8,int8,int16,int32,int64。
- **other** - ``y`` 的别名,行为完全一致。
- **out** (Tensor,可选)- 输出的结果 `Tensor`,是与输入数据类型相同的 N-D `Tensor`。默认值为 None,此时将创建新的 Tensor 来保存输出结果。
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。

Expand Down
5 changes: 5 additions & 0 deletions docs/api/paddle/broadcast_to_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,16 @@ broadcast_to
:width: 500
:align: center

.. note::
别名支持: 参数名 ``input`` 可替代 ``x``和 ``size`` 可替代 ``shape``,如 ``input=tensor_x`` 等价于 ``x=tensor_x``, ``size=[2, 3]`` 等价于 ``shape=[2, 3]``。

参数
:::::::::

- **x** (Tensor) - 输入的 Tensor,数据类型为:bool、float16、float32、float64、int32、int64、uint8 或 uint16。
- **input** - ``x`` 的别名,行为完全一致。
- **shape** (tuple|list|Tensor) - 给定输入 ``x`` 扩展后的形状,若 ``shape`` 为 list 或者 tuple,则其中的元素值应该为整数或者是形状为 1-D 或 0-D 的 Tensor,若 ``shape`` 类型为 Tensor,则其应该为 1-D Tensor。
- **size** - ``shape`` 的别名,行为完全一致。
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。

返回
Expand Down
5 changes: 5 additions & 0 deletions docs/api/paddle/diff_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@ diff
.. note::
高阶的前向差值可以通过递归的方式进行计算,`n`的值支持任意正整数。

.. note::
别名支持: 参数名 ``input`` 可替代 ``x``和 ``dim`` 可替代 ``axis``,如 ``input=tensor_x`` 等价于 ``x=tensor_x``, ``dim=1`` 等价于 ``axis=1``。

参数
::::::::::::

- **x** (Tensor) - 待计算前向差值的输入 `Tensor`,支持 bool、int32、int64、float16、float32、float64 数据类型。
- **input** - ``x`` 的别名,行为完全一致。
- **n** (int,可选) - 需要计算前向差值的次数,`n`的值支持任意正整数,默认值为 1。
- **axis** (int,可选) - 沿着哪一维度计算前向差值,默认值为-1,也即最后一个维度。
- **dim** - ``axis`` 的别名,行为完全一致。
- **prepend** (Tensor,可选) - 在计算前向差值之前,沿着指定维度 axis 附加到输入 x 的前面,它的维度需要和输入一致,并且除了 axis 维外,其他维度的形状也要和输入一致,默认值为 None。
- **append** (Tensor,可选) - 在计算前向差值之前,沿着指定维度 axis 附加到输入 x 的后面,它的维度需要和输入一致,并且除了 axis 维外,其他维度的形状也要和输入一致,默认值为 None。
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。
Expand Down
8 changes: 7 additions & 1 deletion docs/api/paddle/median_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@ median

沿给定的轴 ``axis`` 计算 ``x`` 中元素的中位数。

.. note::
别名支持: 参数名 ``input`` 可替代 ``x``和 ``dim`` 可替代 ``axis``,如 ``input=tensor_x`` 等价于 ``x=tensor_x``, ``dim=1`` 等价于 ``axis=1``。
当出现别名替换时, ``mode`` 设置默认参数为 ``min`` 而不是 ``avg``。

参数
::::::::::
- **x** (Tensor) - 输入的 Tensor,数据类型为:bfloat16、float16、float32、float64、int32、int64。
- **input** - ``x`` 的别名,行为完全一致。
- **axis** (int,可选) - 指定对 ``x`` 进行计算的轴。``axis`` 可以是 int。``axis`` 值应该在范围 [-D, D) 内,D 是 ``x`` 的维度。如果 ``axis`` 或者其中的元素值小于 0,则等价于 :math:`axis + D`。如果 ``axis`` 是 None,则对 ``x`` 的全部元素计算中位数。默认值为 None。
- **dim** - ``axis`` 的别名,行为完全一致。
- **keepdim** (bool,可选) - 是否在输出 Tensor 中保留输入的维度。除非 keepdim 为 True,否则输出 Tensor 的维度将比输入 Tensor 小一维,默认值为 False。
- **mode** (str,可选) - 当输入 Tensor ``x`` 在 ``axis`` 轴上有偶数个元素时,可选择按照中间两个数的平均值或最小值确定中位数。可选的值是 'avg' 或 'min'。默认为 'avg'。
- **mode** (str,可选) - 当输入 Tensor ``x`` 在 ``axis`` 轴上有偶数个元素时,可选择按照中间两个数的平均值或最小值确定中位数。可选的值是 'avg' 或 'min'。默认为 'avg'。当出现别名替换时, ``mode`` 设置默认参数为 ``min`` 而不是 ``avg``。
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。

返回
Expand Down
12 changes: 8 additions & 4 deletions docs/api/paddle/nn/functional/embedding_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ embedding



嵌入层(Embedding Layer),根据 input 中的 id 信息从 embedding 矩阵中查询对应 embedding 信息,并会根据输入的 size (vocab_size, emb_size)和 dtype 自动构造一个二维 embedding 矩阵。
嵌入层(Embedding Layer),根据 x 中的 id 信息从 embedding 矩阵中查询对应 embedding 信息,并会根据输入的 size (vocab_size, emb_size)和 dtype 自动构造一个二维 embedding 矩阵。

输出的 Tensor 的 shape 是将输入 Tensor shape 后追加一维 emb_size。

.. note::

input 中的 id 必须满足 ``0 =< id < size[0]``,否则程序会抛异常退出。
x 中的 id 必须满足 ``0 =< id < size[0]``,否则程序会抛异常退出。

.. note::
别名支持: 参数名 ``input`` 可替代 ``x``,如 ``input=tensor_x`` 等价于 ``x=tensor_x``。


.. code-block:: text
Expand All @@ -39,7 +42,8 @@ embedding
::::::::::::


- **input** (Tensor) - 存储 id 信息的 Tensor,数据类型必须为:int32/int64。input 中的 id 必须满足 ``0 =< id < size[0]`` 。
- **x** (Tensor) - 存储 id 信息的 Tensor,数据类型必须为:int32/int64。input 中的 id 必须满足 ``0 =< id < size[0]`` 。
- **input** - ``x`` 的别名,行为完全一致。
- **weight** (Tensor) - 存储词嵌入权重参数的 Tensor,形状为(num_embeddings, embedding_dim)。
- **padding_idx** (int|long|None,可选) - padding_idx 的配置区间为 ``[-weight.shape[0], weight.shape[0]``,如果配置了 padding_idx,那么在训练过程中遇到此 id 时,其参数及对应的梯度将会以 0 进行填充。如果 padding_idx < 0 ,则 padding_idx 将自动转换到 ``weight.shape[0] + padding_idx`` 。如果设置为 "None",则不会对输出产生影响。默认值:None。
- **max_norm** (float,可选) - 若声明,会将范数大于此值的词嵌入向量重新归一化,使其范数等于此值。在动态图模式下会对 ``weight`` 产生 inplace 修改。默认值为 None。
Expand All @@ -51,7 +55,7 @@ embedding

返回
::::::::::::
Tensor, input 映射后得到的 Embedding Tensor,数据类型和权重定义的类型一致。
Tensor, x 映射后得到的 Embedding Tensor,数据类型和权重定义的类型一致。


代码示例
Expand Down
3 changes: 3 additions & 0 deletions docs/api/paddle/no_grad_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ no_grad

也可以用作一个装饰器(需要创建实例对象作为装饰器)。

.. note::
别名支持: 参数名 ``orig_func`` 可替代 ``func``。

代码示例
::::::::::::

Expand Down
4 changes: 4 additions & 0 deletions docs/api/paddle/ones_like_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ ones_like

返回一个和输入参数 ``x`` 具有相同形状的数值都为 1 的 Tensor,数据类型为 ``dtype`` 或者和 ``x`` 相同,如果 ``dtype`` 为 None,则输出 Tensor 的数据类型与 ``x`` 相同。

.. note::
别名支持: 参数名 ``input`` 可替代 ``x``,如 ``input=tensor_x`` 等价于 ``x=tensor_x``。

参数
::::::::::
- **x** (Tensor) – 输入的 Tensor,数据类型可以是 bool,float16,float32,float64,int32,int64。
- **input** - ``x`` 的别名,行为完全一致。
- **dtype** (str|np.dtype,可选) - 输出 Tensor 的数据类型,支持 bool,float16, float32,float64,int32,int64。当该参数值为 None 时,输出 Tensor 的数据类型与 ``x`` 相同。默认值为 None。
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。

Expand Down
5 changes: 5 additions & 0 deletions docs/api/paddle/prod_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@ prod

对指定维度上的 Tensor 元素进行求乘积运算,并输出相应的计算结果。

.. note::
别名支持: 参数名 ``input`` 可替代 ``x``和 ``dim`` 可替代 ``axis``,如 ``input=tensor_x`` 等价于 ``x=tensor_x``, ``dim=1`` 等价于 ``axis=1``。

参数
::::::::::::

- **x** (Tensor) - 输入的 Tensor,数据类型为:bfloat16、float16、float32、float64、int32、int64、complex64、complex128。
- **input** - ``x`` 的别名,行为完全一致。
- **axis** (int|list|tuple,可选) - 求乘积运算的维度。如果是 None,则计算所有元素的乘积并返回包含单个元素的 Tensor,否则该参数必须在 :math:`[-x.ndim, x.ndim)` 范围内。如果 :math:`axis[i] < 0`,则维度将变为 :math:`x.ndim + axis[i]`,默认为 None。
- **dim** - ``axis`` 的别名,行为完全一致。
- **keepdim** (bool,可选) - 是否在输出 Tensor 中保留输入的维度。除非 keepdim 为 True,否则输出 Tensor 的维度将比输入 Tensor 小一维,默认值为 False。
- **dtype** (str,可选) - 输出 Tensor 的数据类型,支持 int32、int64、float32、float64。如果指定了该参数,那么在执行操作之前,输入 Tensor 将被转换为 dtype 类型。这对于防止数据类型溢出非常有用。若参数为空,则输出变量的数据类型和输入变量相同,默认为:None。
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。
Expand Down
5 changes: 5 additions & 0 deletions docs/api/paddle/repeat_interleave_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@ repeat_interleave
:alt: 示例一图示
:align: center

.. note::
别名支持: 参数名 ``input`` 可替代 ``x``和 ``dim`` 可替代 ``axis``,如 ``input=tensor_x`` 等价于 ``x=tensor_x``, ``dim=1`` 等价于 ``axis=1``。

参数
:::::::::
- **x** (Tensor)– 输入 Tensor。 ``x`` 的数据类型可以是 float32,float64,int32,int64。
- **input** - ``x`` 的别名,行为完全一致。
- **repeats** (Tensor, int)– 包含复制次数的 1-D Tensor 或指定的复制次数。
- **axis** (int,可选) – 指定对输入 ``x`` 进行运算的轴,若未指定,默认值为 None,使用输入 Tensor 的 flatten 形式。
- **dim** - ``axis`` 的别名,行为完全一致。
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。


Expand Down
4 changes: 4 additions & 0 deletions docs/api/paddle/sparse/reshape_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ reshape
- 2. 给定一个形状为[2,4,6]的三维 Tensor x ,目标形状为[2,3,-1,2],则将 x 变换为形状为[2,3,4,2]的 4-D Tensor,且 x 的数据保持不变。在这种情况下,目标形状的一个维度被设置为 -1 ,这个维度的值是从 x 的元素总数和剩余维度推断出来的。
- 3. 给定一个形状为[2,4,6]的三维 Tensor x ,目标形状为[-1,0,3,2],则将 x 变换为形状为[2,4,3,2]的 4-D Tensor,且 x 的数据保持不变。在这种情况下, 0 对应位置的维度值将从 x 的对应维数中复制,-1 对应位置的维度值由 x 的元素总数和剩余维度推断出来。

.. note::
别名支持: 参数名 ``input`` 可替代 ``x``,如 ``input=tensor_x`` 等价于 ``x=tensor_x``。

参数
:::::::::

- **x** (Tensor) - ``sparse tensor``,数据类型为 ``float32``、 ``float64``、 ``int32``、 ``int64`` 或者 ``bool``。
- **input** - ``x`` 的别名,行为完全一致。
- **shape** (list|tuple) - 数据类型是 ``int32``。定义目标形状。目标形状最多只能有一个维度为 -1 。
- **name** (str ,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None 。

Expand Down
5 changes: 5 additions & 0 deletions docs/api/paddle/take_along_axis_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ take_along_axis
.. py:function:: paddle.take_along_axis(arr, indices, axis, broadcast=True)
基于输入索引矩阵,沿着指定 axis 从 arr 矩阵里选取 1d 切片。索引矩阵必须和 arr 矩阵有相同的维度,需要能够 broadcast 与 arr 矩阵对齐。

.. note::
别名支持: 参数名 ``input`` 可替代 ``arr``和 ``dim`` 可替代 ``axis``,如 ``input=tensor_arr`` 等价于 ``arr=tensor_arr``, ``dim=1`` 等价于 ``axis=1``。

参数
:::::::::

- **arr** (Tensor) - 输入的 Tensor 作为源矩阵,数据类型为:bfloat16、float16、float32、float64、int32、int64、uint8。
- **input** - ``x`` 的别名,行为完全一致。
- **indices** (Tensor) - 索引矩阵,包含沿轴提取 1d 切片的下标,必须和 arr 矩阵有相同的维度,需要能够 broadcast 与 arr 矩阵对齐,数据类型为:int32、int64。
- **axis** (int) - 指定沿着哪个维度获取对应的值,数据类型为:int。
- **dim** - ``axis`` 的别名,行为完全一致。
- **broadcast** (bool,可选) - 是否广播 ``index`` 矩阵,默认为 ``True``。

返回
Expand Down
5 changes: 5 additions & 0 deletions docs/api/paddle/unique_consecutive_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,18 @@ unique_consecutive
:alt: 示例二图示
:align: center

.. note::
别名支持: 参数名 ``input`` 可替代 ``x``和 ``dim`` 可替代 ``axis``,如 ``input=tensor_x`` 等价于 ``x=tensor_x``, ``dim=1`` 等价于 ``axis=1``。

参数
::::::::::::

- **x** (Tensor) - 输入的 `Tensor`,数据类型为:float32、float64、int32、int64。
- **input** - ``x`` 的别名,行为完全一致。
- **return_inverse** (bool,可选) - 如果为 True,则还返回输入 Tensor 的元素对应在连续不重复元素中的索引,该索引可用于重构输入 Tensor。默认:False。
- **return_counts** (bool,可选) - 如果为 True,则还返回每个连续不重复元素在输入 Tensor 中的个数。默认:False。
- **axis** (int,可选) - 指定选取连续不重复元素的轴。默认值为 None,将输入平铺为 1-D 的 Tensor 后再选取连续不重复元素。默认:None。
- **dim** - ``axis`` 的别名,行为完全一致。
- **dtype** (np.dtype|str,可选) - 用于设置 `inverse` 或者 `counts` 的类型,应该为 int32 或者 int64。默认:int64。
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。

Expand Down
5 changes: 5 additions & 0 deletions docs/api/paddle/var_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ var

沿给定的轴 ``axis`` 计算 ``x`` 中元素的方差。

.. note::
别名支持: 参数名 ``input`` 可替代 ``x``和 ``dim`` 可替代 ``axis``,如 ``input=tensor_x`` 等价于 ``x=tensor_x``, ``dim=1`` 等价于 ``axis=1``。

参数
::::::::::
- **x** (Tensor) - 输入的 Tensor,数据类型为:float16、float32、float64。
- **input** - ``x`` 的别名,行为完全一致。
- **axis** (int|list|tuple,可选) - 指定对 ``x`` 进行计算的轴。``axis`` 可以是 int、list(int)、tuple(int)。

- 如果 ``axis`` 包含多个维度,则沿着 ``axis`` 中的所有轴进行计算。``axis`` 或者其中的元素值应该在范围[-D, D)内,D 是 ``x`` 的维度。
Expand All @@ -18,6 +22,7 @@ var

- **unbiased** (bool,可选) - 是否使用无偏估计来计算方差。使用 :math:`N` 来代表在 axis 上的维度,如果 ``unbiased`` 为 True,则在计算中使用 :math:`N - 1` 作为除数。为 False 时将使用 :math:`N` 作为除数。默认值为 True。
- **keepdim** (bool,可选) - 是否在输出 Tensor 中保留输入的维度。除非 keepdim 为 True,否则输出 Tensor 的维度将比输入 Tensor 小一维,默认值为 False。
- **dim** - ``axis`` 的别名,行为完全一致。
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。

返回
Expand Down
10 changes: 10 additions & 0 deletions docs/api/paddle/view_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,21 @@ view

仅在动态图下可用,返回的 Tensor 和 x 共享内存。

.. note::
别名支持: 参数名 ``size`` 和 ``dtype`` 可替代 ``shape_or_dtype``。
``shape_or_dtype`` 支持可变参数类型。
使用实例:
``tensor_x.view(dtype=paddle.float32)``
``tensor_x.view(size=[-1, 1, 3])``
``tensor_x.view(-1, 1, 3)``

参数
:::::::::

- **x** (Tensor) - 输入多维 Tensor,可选的数据类型为 'float16'、'float32'、'float64'、'int16'、'int32'、'int64'、'bool'、'uint16'。
- **shape_or_dtype** (list|tuple|np.dtype|str|VarType) - 指定的新的 shape 或者 dtype。如果是 list 或者 tuple,则代表 shape,否则代表 dtype。
- **size** - ``shape_or_dtype`` 的别名,行为完全一致。
- **dtype** - ``shape_or_dtype`` 的别名,行为完全一致。
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。

返回
Expand Down
10 changes: 9 additions & 1 deletion docs/api/paddle/zeros_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,18 @@ zeros

创建形状为 ``shape`` 、数据类型为 ``dtype`` 且值全为 0 的 Tensor。

.. note::
别名支持: 参数名 ``size`` 可替代 ``shape``。
``shape`` 支持可变参数类型.
使用实例:
``paddle.ones(1, 2, 3, dtype=paddle.float32)``
``paddle.ones(size=[1, 2, 3], dtype=paddle.float32)``

参数
::::::::::::

- **shape** (tuple|list|Tensor) - 输出 Tensor 的形状,``shape`` 的数据类型为 int32 或者 int64。
- **shape** (tuple|list|Tensor) - 输出 Tensor 的形状,``shape`` 的数据类型为 int32 或者 int64,支持可变参数类型.
- **size** - ``shape`` 的别名,行为完全一致。
- **dtype** (np.dtype|str,可选) - 输出 Tensor 的数据类型,数据类型必须为 bool、float16、float32、float64、int32 或 int64。若为 None,数据类型为 float32,默认为 None。
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。

Expand Down