Skip to content
Merged
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
2 changes: 2 additions & 0 deletions docs/api/paddle/Overview_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ tensor 线性代数相关
" :ref:`paddle.histogram_bin_edges <cn_api_paddle_histogram_bin_edges>` ", "返回计算 input 的直方图时所使用的 bins 的边界值 bin_edges"
" :ref:`paddle.histogram <cn_api_paddle_histogram>` ", "计算输入 Tensor 的直方图"
" :ref:`paddle.histogramdd <cn_api_paddle_histogramdd>` ", "计算输入多维 Tensor 的直方图"
" :ref:`paddle.inverse <cn_api_paddle_inverse>` ", "计算方阵的逆矩阵"
" :ref:`paddle.matmul <cn_api_paddle_matmul>` ", "计算两个 Tensor 的乘积,遵循完整的广播规则"
" :ref:`paddle.mv <cn_api_paddle_mv>` ", "计算矩阵 x 和向量 vec 的乘积"
" :ref:`paddle.rank <cn_api_paddle_rank>` ", "计算输入 Tensor 的维度(秩)"
Expand Down Expand Up @@ -613,6 +614,7 @@ framework 相关
:header: "API 名称", "API 功能"
:widths: 10, 30

" :ref:`paddle._assert <cn_api_paddle__assert>` ", "对 Python assert 的封装,支持符号追踪"
" :ref:`paddle.CPUPlace <cn_api_paddle_CPUPlace>` ", "一个设备描述符,指定 CPUPlace 则 Tensor 将被自动分配在该设备上,并且模型将会运行在该设备上"
" :ref:`paddle.CUDAPinnedPlace <cn_api_paddle_CUDAPinnedPlace>` ", "一个设备描述符,它所指代的页锁定内存由 CUDA 函数 cudaHostAlloc() 在主机内存上分配,主机的操作系统将不会对这块内存进行分页和交换操作,可以通过直接内存访问技术访问,加速主机和 GPU 之间的数据拷贝"
" :ref:`paddle.CUDAPlace <cn_api_paddle_CUDAPlace>` ", "一个设备描述符,表示一个分配或将要分配 Tensor 的 GPU 设备"
Expand Down
8 changes: 4 additions & 4 deletions docs/api/paddle/Tensor__upper_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4020,7 +4020,7 @@ new_full(size, fill_value, \*, dtype=None, device=None, requires_grad=False, pin
- **out** (Tensor,可选) - 用于保存输出结果的 Tensor,默认值为 None。
- **device** (PlaceLike|None,可选) - 期望创建 Tensor 所在的设备。若为 None,则与 ``self`` 保持一致。
- **requires_grad** (bool,可选) - 是否需要为返回的 Tensor 记录梯度信息。默认值为 False。
- **pin_memory** (bool,可选) - 若为 True,返回的 CPU Tensor 将分配在锁页内存中。仅对 CPU Tensor 生效。默认值为 False。
- **pin_memory** (bool,可选) - 若为 True,返回的 Tensor 将分配在锁页内存中。默认值为 False。

返回:
- **Tensor**,其形状为 ``shape``,元素值为 ``fill_value``,数据类型为 ``dtype``(若未指定,则与 ``self`` 一致)。
Expand All @@ -4044,7 +4044,7 @@ new_ones(size, \*, dtype=None, device=None, requires_grad=False, pin_memory=Fals
- **out** (Tensor,可选) - 用于保存输出结果的 Tensor,默认值为 None。
- **device** (PlaceLike|None,可选) - 期望创建 Tensor 所在的设备。若为 None,则与 ``self`` 保持一致。
- **requires_grad** (bool,可选) - 是否需要为返回的 Tensor 记录梯度信息。默认值为 False。
- **pin_memory** (bool,可选) - 若为 True,返回的 CPU Tensor 将分配在锁页内存中。仅对 CPU Tensor 生效。默认值为 False。
- **pin_memory** (bool,可选) - 若为 True,返回的 Tensor 将分配在锁页内存中。默认值为 False。

返回:
- **Tensor**,其形状为 ``shape``,元素值为 ``1``,数据类型为 ``dtype``(若未指定,则与 ``self`` 一致)。
Expand All @@ -4068,7 +4068,7 @@ new_zeros(size, \*, dtype=None, device=None, requires_grad=False, pin_memory=Fal
- **out** (Tensor,可选) - 用于保存输出结果的 Tensor,默认值为 None。
- **device** (PlaceLike|None,可选) - 期望创建 Tensor 所在的设备。若为 None,则与 ``self`` 保持一致。
- **requires_grad** (bool,可选) - 是否需要为返回的 Tensor 记录梯度信息。默认值为 False。
- **pin_memory** (bool,可选) - 若为 True,返回的 CPU Tensor 将分配在锁页内存中。仅对 CPU Tensor 生效。默认值为 False。
- **pin_memory** (bool,可选) - 若为 True,返回的 Tensor 将分配在锁页内存中。默认值为 False。

返回:
- **Tensor**,其形状为 ``shape``,元素值为 ``0``,数据类型为 ``dtype``(若未指定,则与 ``self`` 一致)。
Expand All @@ -4092,7 +4092,7 @@ new_empty(size, \*, dtype=None, device=None, requires_grad=False, pin_memory=Fal
- **out** (Tensor,可选) - 用于保存输出结果的 Tensor,默认值为 None。
- **device** (PlaceLike|None,可选) - 期望创建 Tensor 所在的设备。若为 None,则与 ``self`` 保持一致。
- **requires_grad** (bool,可选) - 是否需要为返回的 Tensor 记录梯度信息。默认值为 False。
- **pin_memory** (bool,可选) - 若为 True,返回的 CPU Tensor 将分配在锁页内存中。仅对 CPU Tensor 生效。默认值为 False。
- **pin_memory** (bool,可选) - 若为 True,返回的 Tensor 将分配在锁页内存中。默认值为 False。

返回:
- **Tensor**,其形状为 ``shape``,元素值为 ``0``(一般情况下为 ``0``,但也有可能为随机值),数据类型为 ``dtype``(若未指定,则与 ``self`` 一致)。
Expand Down
28 changes: 28 additions & 0 deletions docs/api/paddle/_assert_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.. _cn_api_paddle__assert:

_assert
-------------------------------

.. py:function:: paddle._assert(condition, message="")

对 Python assert 的封装,支持符号追踪。

在动态图模式下,该函数的行为与 Python 的 assert 语句一致。在静态图模式下,当 condition 是 Tensor 时,会在计算图中创建一个 Assert 算子。

参数
::::::::::::
- **condition** (bool|Tensor) - 断言的条件。如果是 Tensor,必须是布尔标量(numel=1)。
- **message** (str,可选) - 断言失败时显示的错误信息。默认值为 ""。

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

.. code-block:: pycon

>>> import paddle
>>> # Non-tensor condition
>>> paddle._assert(1 == 1, "This should pass")

>>> # Tensor condition
>>> x = paddle.to_tensor([True])
>>> paddle._assert(x, "Tensor assertion")
4 changes: 2 additions & 2 deletions docs/api/paddle/allclose_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ allclose
参数
::::::::::::

- **x** (Tensor) - 输入的 ``Tensor``,数据类型为:float16、float32、float64。
- **y** (Tensor) - 输入的 ``Tensor``,数据类型为:float16、float32、float64。
- **x** (Tensor) - 输入的 ``Tensor``,数据类型为:float16、float32、float64。别名 ``input``。
- **y** (Tensor) - 输入的 ``Tensor``,数据类型为:float16、float32、float64。别名 ``other``。
- **rtol** (float,可选) - 相对容忍误差,默认值为 1e-5。
- **atol** (float,可选) - 绝对容忍误差,默认值为 1e-8。
- **equal_nan** (bool,可选) - 如果设置为 True,则两个 NaN 数值将被视为相等,默认值为 False。
Expand Down
17 changes: 12 additions & 5 deletions docs/api/paddle/amp/GradScaler_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,21 @@ GradScaler 用于动态图模式下的"自动混合精度"的训练。它控制

通常,GradScaler 和 ``paddle.amp.auto_cast`` 一起使用,来实现动态图模式下的"自动混合精度"。

本 API 支持三种调用方式:

1. ``GradScaler(enable=True, init_loss_scaling=2.0**16, incr_ratio=2.0, decr_ratio=0.5, incr_every_n_steps=2000, decr_every_n_nan_or_inf=1, use_dynamic_loss_scaling=True)``

2. ``GradScaler(device, init_scale=2.0**16, growth_factor=2.0, backoff_factor=0.5, growth_interval=2000, enabled=True)``

3. ``GradScaler(init_scale=2.0**16, growth_factor=2.0, backoff_factor=0.5, growth_interval=2000, enabled=True)``

参数
:::::::::
- **enable** (bool,可选) - 是否使用 loss scaling。默认值为 True。
- **init_loss_scaling** (float,可选) - 初始 loss scaling 因子。默认值为 65536.0。
- **incr_ratio** (float,可选) - 增大 loss scaling 时使用的乘数。默认值为 2.0。
- **decr_ratio** (float,可选) - 减小 loss scaling 时使用的小于 1 的乘数。默认值为 0.5。
- **incr_every_n_steps** (int,可选) - 连续 n 个 steps 的梯度都是有限值时,增加 loss scaling。默认值为 2000。
- **enable** (bool,可选) - 是否使用 loss scaling。默认值为 True。别名 ``enabled``。
- **init_loss_scaling** (float,可选) - 初始 loss scaling 因子。默认值为 65536.0。别名 ``init_scale``。
- **incr_ratio** (float,可选) - 增大 loss scaling 时使用的乘数。默认值为 2.0。别名 ``growth_factor``。
- **decr_ratio** (float,可选) - 减小 loss scaling 时使用的小于 1 的乘数。默认值为 0.5。别名 ``backoff_factor``。
- **incr_every_n_steps** (int,可选) - 连续 n 个 steps 的梯度都是有限值时,增加 loss scaling。默认值为 2000。别名 ``growth_interval``。
- **decr_every_n_nan_or_inf** (int,可选) - 累计出现 n 个 steps 的梯度为 nan 或者 inf 时,减小 loss scaling。默认值为 1。
- **use_dynamic_loss_scaling** (bool,可选) - 是否使用动态的 loss scaling。如果不使用,则使用固定的 loss scaling;如果使用,则会动态更新 loss scaling。默认值为 True。

Expand Down
2 changes: 1 addition & 1 deletion docs/api/paddle/arange_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ arange
- **out** (Tensor,可选) - 用于存储结果的 Tensor。若指定,将直接写入该 Tensor,默认值为 None。
- **device** (PlaceLike|None,可选) - 期望创建 Tensor 所在的设备。默认值为 None,表示使用当前全局设备(可通过 ``paddle.device.set_device`` 设置)。
- **requires_grad** (bool,可选) - 是否需要为返回的 Tensor 记录梯度信息。默认值为 False。
- **pin_memory** (bool,可选) - 若为 True,返回的 CPU Tensor 将分配在锁页内存中。仅对 CPU Tensor 生效。默认值为 False。
- **pin_memory** (bool,可选) - 若为 True,返回的 Tensor 将分配在锁页内存中。默认值为 False。
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。

返回
Expand Down
6 changes: 5 additions & 1 deletion docs/api/paddle/deg2rad_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
deg2rad
-------------------------------

.. py:function:: paddle.deg2rad(x, name=None)
.. py:function:: paddle.deg2rad(x, name=None, *, out=None)

将元素从度转换为弧度

Expand All @@ -17,6 +17,10 @@ deg2rad
- **x** (Tensor) - 输入的 Tensor,数据类型为:int32、int64、float32、float64。
- **name** (str,可选) - 操作的名称(可选,默认值为 None)。更多信息请参见 :ref:`api_guide_Name`。

关键字参数
:::::::::
- **out** (Tensor,可选) - 输出 Tensor,若不为 ``None``,计算结果将保存在该 Tensor 中,默认值为 ``None``。

返回
:::::::::

Expand Down
2 changes: 1 addition & 1 deletion docs/api/paddle/empty_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ empty
- **out** (Tensor,可选) - 用于存储结果的 Tensor。若指定,将直接写入该 Tensor,默认值为 None。
- **device** (PlaceLike|None,可选) - 期望创建 Tensor 所在的设备。默认值为 None,表示使用当前全局设备(可通过 ``paddle.device.set_device`` 设置)。
- **requires_grad** (bool,可选) - 是否需要为返回的 Tensor 记录梯度信息。默认值为 False。
- **pin_memory** (bool,可选) - 若为 True,返回的 CPU Tensor 将分配在锁页内存中。仅对 CPU Tensor 生效。默认值为 False。
- **pin_memory** (bool,可选) - 若为 True,返回的 Tensor 将分配在锁页内存中。默认值为 False。

返回
::::::::::::
Expand Down
2 changes: 1 addition & 1 deletion docs/api/paddle/empty_like_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ empty_like
::::::::::::
- **device** (PlaceLike|None,可选) - 期望创建 Tensor 所在的设备。若为 None,则与 ``x`` 保持一致。
- **requires_grad** (bool,可选) - 是否需要为返回的 Tensor 记录梯度信息。默认值为 False。
- **pin_memory** (bool,可选) - 若为 True,返回的 CPU Tensor 将分配在锁页内存中。仅对 CPU Tensor 生效。默认值为 False。
- **pin_memory** (bool,可选) - 若为 True,返回的 Tensor 将分配在锁页内存中。默认值为 False。

返回
::::::::::::
Expand Down
2 changes: 1 addition & 1 deletion docs/api/paddle/eye_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ eye
- **device** (PlaceLike|None,可选) - 指定返回 Tensor 所在的设备。默认值为 None,表示使用当前全局设备(可通过 ``paddle.device.set_device`` 设置)。
对于 CPU Tensor,设备为 CPU;对于 CUDA Tensor,设备为当前 CUDA 设备。默认值为 None。
- **requires_grad** (bool,可选) - 是否在返回的 Tensor 上记录 autograd 的操作。默认值为 False。
- **pin_memory** (bool,可选) - 若设置为 True,则返回的 Tensor 将分配在锁页内存中。仅对 CPU Tensor 生效。默认值为 False。
- **pin_memory** (bool,可选) - 若设置为 True,则返回的 Tensor 将分配在锁页内存中。默认值为 False。

返回
::::::::::::
Expand Down
2 changes: 1 addition & 1 deletion docs/api/paddle/full_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ full
- **out** (Tensor,可选) - 用于存储结果的 Tensor。若指定,将直接写入该 Tensor,默认值为 None。
- **device** (PlaceLike|None,可选) - 期望创建 Tensor 所在的设备。默认值为 None,表示使用当前全局设备(可通过 ``paddle.device.set_device`` 设置)。
- **requires_grad** (bool,可选) - 是否需要为返回的 Tensor 记录梯度信息。默认值为 False。
- **pin_memory** (bool,可选) - 若为 True,返回的 CPU Tensor 将分配在锁页内存中。仅对 CPU Tensor 生效。默认值为 False。
- **pin_memory** (bool,可选) - 若为 True,返回的 Tensor 将分配在锁页内存中。默认值为 False。

返回
::::::::::::
Expand Down
2 changes: 1 addition & 1 deletion docs/api/paddle/full_like_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ full_like
::::::::::::
- **device** (PlaceLike|None,可选) - 期望创建 Tensor 所在的设备。若为 None,则与 ``x`` 保持一致。
- **requires_grad** (bool,可选) - 是否需要为返回的 Tensor 记录梯度信息。默认值为 False。
- **pin_memory** (bool,可选) - 若为 True,返回的 CPU Tensor 将分配在锁页内存中。仅对 CPU Tensor 生效。默认值为 False。
- **pin_memory** (bool,可选) - 若为 True,返回的 Tensor 将分配在锁页内存中。默认值为 False。

返回
::::::::::::
Expand Down
26 changes: 26 additions & 0 deletions docs/api/paddle/inverse_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.. _cn_api_paddle_inverse:

inverse
-------------------------------

.. py:function:: paddle.inverse(x, name=None, *, out=None)

计算方阵的逆矩阵。方阵是行数和列数相同的矩阵。输入可以是一个方阵(2-D Tensor)或者多个方阵组成的 batch(batch of square matrices)。

参数
::::::::::::
- **x** (Tensor) - 输入 Tensor,最后两个维度应相等。当维度大于 2 时,视为方阵的 batch。数据类型为 float32、float64、complex64、complex128。别名 ``input``。
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。

关键字参数
::::::::::::
- **out** (Tensor,可选) - 输出 Tensor,若不为 ``None``,计算结果将保存在该 Tensor 中,默认值为 ``None``。

返回
::::::::::::
Tensor,``x`` 的逆矩阵,维度和数据类型与 ``x`` 相同。

代码示例
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

代码示例需要用 COPY-FROM 的方式来写

::::::::::::

COPY-FROM: paddle.inverse
10 changes: 7 additions & 3 deletions docs/api/paddle/lerp_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,23 @@
lerp
-------------------------------

.. py:function:: paddle.lerp(x, y, weight, name=None)
.. py:function:: paddle.lerp(x, y, weight, name=None, *, out=None)
基于给定的 weight 计算 x 与 y 的线性插值

.. math::
lerp(x, y, weight) = x + weight * (y - x)
参数
:::::::::

- **x** (Tensor) - 输入的 Tensor,作为线性插值开始的点,数据类型为:bfloat16、float16、float32、float64。
- **y** (Tensor) - 输入的 Tensor,作为线性插值结束的点,数据类型为:bfloat16、float16、float32、float64。
- **x** (Tensor) - 输入的 Tensor,作为线性插值开始的点,数据类型为:bfloat16、float16、float32、float64。别名 ``input``。
- **y** (Tensor) - 输入的 Tensor,作为线性插值结束的点,数据类型为:bfloat16、float16、float32、float64。别名 ``end``。
- **weight** (float|Tensor) - 给定的权重值,weight 为 Tensor 时数据类型为:bfloat16、float16、float32、float64。
- **name** (str,可选) - 操作的名称(可选,默认值为 None)。更多信息请参见 :ref:`api_guide_Name`。

关键字参数
:::::::::
- **out** (Tensor,可选) - 输出 Tensor,若不为 ``None``,计算结果将保存在该 Tensor 中,默认值为 ``None``。

返回
:::::::::

Expand Down
10 changes: 7 additions & 3 deletions docs/api/paddle/logit_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
logit
-------------------------------

.. py:function:: paddle.logit(x, eps=None, name=None)
.. py:function:: paddle.logit(x, eps=None, name=None, *, out=None)

实现了 logit 层。若 eps 为默认值 None,并且 ``x`` < 0 或者 ``x`` > 1,该函数将返回 NaN,计算公式如下:

Expand All @@ -25,13 +25,17 @@ logit

参数
::::::::::::
- **x** (Tensor) - 输入的 ``Tensor``,数据类型为:float32、float64。
- **x** (Tensor) - 输入的 ``Tensor``,数据类型为:bfloat16、float16、float32、float64、uint8、int8、int16、int32、int64。别名 ``input``
- **eps** (float,可选) - 传入该参数后可将 ``x`` 的范围控制在 :math:`[eps, 1-eps]`,默认值为 None。
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。

关键字参数
::::::::::::
- **out** (Tensor,可选) - 输出 Tensor,若不为 ``None``,计算结果将保存在该 Tensor 中,默认值为 ``None``。

返回
::::::::::
``Tensor``,数据类型和形状同 ``x`` 一致。
``Tensor``,形状同 ``x`` 一致(整数类型会自动转换为 float32)

代码示例
::::::::::
Expand Down
10 changes: 7 additions & 3 deletions docs/api/paddle/mm_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
mm
-------------------------------

.. py:function:: paddle.mm(input, mat2, name=None)
.. py:function:: paddle.mm(input, mat2, name=None, *, out=None)



Expand All @@ -17,10 +17,14 @@ mm
参数
::::::::::::

- **input** (Tensor)输入变量,类型为 Tensor。
- **mat2** (Tensor)输入变量,类型为 Tensor。
- **input** (Tensor) - 输入变量,类型为 Tensor。支持的数据类型:bfloat16、float16、float32、float64、int8、int32、int64、complex64、complex128
- **mat2** (Tensor) - 输入变量,类型为 Tensor。支持的数据类型:bfloat16、float16、float32、float64、int8、int32、int64、complex64、complex128
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。

关键字参数
::::::::::::
- **out** (Tensor,可选) - 输出 Tensor,若不为 ``None``,计算结果将保存在该 Tensor 中,默认值为 ``None``。

返回
::::::::::::

Expand Down
Loading