Skip to content

Commit 148b6c6

Browse files
zhwesky2010claude
andcommitted
[API Compatibility] addmv/addr/enable_grad/histc/fix/special.round/logaddexp/logspace/moveaxis/nan_to_num/nanmean/nansum/sgn/signbit/slice_scatter/take/tensordot/tril_indices/triu_indices/trunc/vander Edit By AI Agent
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 72829b4 commit 148b6c6

24 files changed

Lines changed: 311 additions & 35 deletions

docs/api/paddle/addmv_cn.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
.. _cn_api_paddle_addmv:
2+
3+
addmv
4+
-------------------------------
5+
6+
.. py:function:: paddle.addmv(input, mat, vec, beta=1.0, alpha=1.0, name=None, *, out=None)
7+
8+
执行矩阵-向量乘法并与输入相加。
9+
10+
计算公式为:
11+
12+
.. math::
13+
14+
out = \beta \cdot input + \alpha \cdot (mat @ vec)
15+
16+
17+
参数
18+
:::::::::
19+
- **input** (Tensor):输入 Tensor,形状为 (n,)。
20+
- **mat** (Tensor):矩阵 Tensor,形状为 (n, m)。
21+
- **vec** (Tensor):向量 Tensor,形状为 (m,)。
22+
- **beta** (float,可选) - input 的乘数,默认值为 1.0。
23+
- **alpha** (float,可选) - mat @ vec 的乘数,默认值为 1.0。
24+
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。
25+
26+
关键字参数
27+
:::::::::
28+
- **out** (Tensor,可选) - 输出 Tensor,若不为 ``None``,计算结果将保存在该 Tensor 中,默认值为 ``None``。
29+
30+
返回
31+
:::::::::
32+
- Tensor,形状为 (n,) 的计算结果。
33+
34+
35+
代码示例
36+
:::::::::
37+
38+
COPY-FROM: paddle.addmv

docs/api/paddle/addr_cn.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
.. _cn_api_paddle_addr:
2+
3+
addr
4+
-------------------------------
5+
6+
.. py:function:: paddle.addr(input, vec1, vec2, beta=1.0, alpha=1.0, name=None, *, out=None)
7+
8+
执行向量的外积并与输入相加。
9+
10+
计算公式为:
11+
12+
.. math::
13+
14+
out = \beta \cdot input + \alpha \cdot (vec1 \otimes vec2)
15+
16+
17+
参数
18+
:::::::::
19+
- **input** (Tensor):输入 Tensor,形状为 (n, m)。
20+
- **vec1** (Tensor):第一个向量 Tensor,形状为 (n,)。
21+
- **vec2** (Tensor):第二个向量 Tensor,形状为 (m,)。
22+
- **beta** (float,可选) - input 的乘数,默认值为 1.0。
23+
- **alpha** (float,可选) - 外积的乘数,默认值为 1.0。
24+
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。
25+
26+
关键字参数
27+
:::::::::
28+
- **out** (Tensor,可选) - 输出 Tensor,若不为 ``None``,计算结果将保存在该 Tensor 中,默认值为 ``None``。
29+
30+
返回
31+
:::::::::
32+
- Tensor,形状为 (n, m) 的计算结果。
33+
34+
35+
代码示例
36+
:::::::::
37+
38+
COPY-FROM: paddle.addr

docs/api/paddle/autograd/Overview_cn.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ paddle.autograd 目录下包含飞桨框架支持的自动微分相关的 API
1919
:widths: 10, 30
2020

2121
" :ref:`backward <cn_api_paddle_autograd_backward>` ", "计算给定的 Tensors 的反向梯度"
22+
" :ref:`enable_grad <cn_api_paddle_autograd_enable_grad>` ", "创建启用动态图梯度计算的上下文"
2223
" :ref:`hessian <cn_api_paddle_autograd_hessian>` ", "计算因变量 ``ys`` 对 自变量 ``xs`` 的海森矩阵"
2324
" :ref:`jacobian <cn_api_paddle_autograd_jacobian>` ", "计算因变量 ``ys`` 对 自变量 ``xs`` 的雅可比矩阵"
2425
" :ref:`saved_tensors_hooks <cn_api_paddle_autograd_saved_tensors_hooks>` ", "用于动态图中为保存的 Tensor 注册一对 pack / unpack hook"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.. _cn_api_paddle_autograd_enable_grad:
2+
3+
enable_grad
4+
-------------------------------
5+
6+
.. py:class:: paddle.autograd.enable_grad()
7+
8+
创建一个启用动态图梯度计算的上下文,如果此前被 `no_grad` 或 `set_grad_enabled` 禁用了梯度计算。
9+
10+
在此模式下,每个计算结果的 `stop_gradient` 属性将被设置为 `False`。
11+
12+
也可作为装饰器使用(请确保使用实例)。
13+
14+
**代码示例**
15+
16+
COPY-FROM: paddle.autograd.enable_grad
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
.. _cn_api_paddle_compat_histc:
2+
3+
histc
4+
-------------------------------
5+
6+
.. py:function:: paddle.compat.histc(input, bins=100, min=0, max=0, name=None, *, out=None)
7+
8+
计算 Tensor 的直方图。
9+
10+
元素被分配到 min 和 max 之间的等宽区间中。如果 min 和 max 都为零,则使用数据的最小值和最大值。
11+
12+
.. note::
13+
此 API 与 PyTorch 兼容,返回值类型为 float32。Paddle 原生 API :ref:`cn_api_paddle_histogram` 返回值类型为 int64。
14+
15+
16+
参数
17+
:::::::::
18+
- **input** (Tensor):输入 Tensor,支持 float32、float64、int32、int64 数据类型。
19+
- **bins** (int,可选) - 直方图的区间数,默认值为 100。
20+
- **min** (float,可选) - 范围的下界(包含),默认值为 0。
21+
- **max** (float,可选) - 范围的上界(包含),默认值为 0。
22+
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。
23+
24+
关键字参数
25+
:::::::::
26+
- **out** (Tensor,可选) - 输出 Tensor,若不为 ``None``,计算结果将保存在该 Tensor 中,默认值为 ``None``。
27+
28+
返回
29+
:::::::::
30+
- Tensor,形状为 (bins,),数据类型为 float32 的直方图结果。
31+
32+
33+
代码示例
34+
:::::::::
35+
36+
COPY-FROM: paddle.compat.histc

docs/api/paddle/fix_cn.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
.. _cn_api_paddle_fix:
2+
3+
fix
4+
-------------------------------
5+
6+
.. py:function:: paddle.fix(input, name=None, *, out=None)
7+
8+
`paddle.fix` 是 `paddle.trunc` 的别名,功能与 `paddle.trunc` 完全一致。
9+
10+
请参见 :ref:`cn_api_paddle_trunc` 获取详细文档。
11+
12+
13+
参数
14+
:::::::::
15+
- **input** (Tensor):输入变量,类型为 Tensor,支持 int32、int64、float32、float64 数据类型。
16+
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。
17+
18+
关键字参数
19+
:::::::::
20+
- **out** (Tensor,可选) - 输出 Tensor,若不为 ``None``,计算结果将保存在该 Tensor 中,默认值为 ``None``。
21+
22+
返回
23+
:::::::::
24+
- Tensor (Tensor),矩阵截断后的结果。
25+
26+
27+
代码示例
28+
:::::::::
29+
30+
COPY-FROM: paddle.fix

docs/api/paddle/histc_cn.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.. _cn_api_paddle_histc:
2+
3+
histc
4+
-------------------------------
5+
6+
.. py:function:: paddle.histc(input, bins=100, min=0.0, max=0.0, name=None, *, out=None)
7+
8+
计算 Tensor 的直方图。
9+
10+
元素被分到 min 和 max 之间等宽的 bin 中。如果 min 和 max 都为 0,则使用数据的最小值和最大值。
11+
12+
13+
参数
14+
:::::::::
15+
- **input** (Tensor):输入 Tensor。
16+
- **bins** (int,可选) - 直方图的 bin 数量,默认值为 100。
17+
- **min** (float,可选) - 范围的下界(包含),默认值为 0.0。
18+
- **max** (float,可选) - 范围的上界(包含),默认值为 0.0。
19+
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。
20+
21+
关键字参数
22+
:::::::::
23+
- **out** (Tensor,可选) - 输出 Tensor,若不为 ``None``,计算结果将保存在该 Tensor 中,默认值为 ``None``。
24+
25+
返回
26+
:::::::::
27+
- Tensor,数据类型为 float32 的直方图结果。
28+
29+
30+
代码示例
31+
:::::::::
32+
33+
COPY-FROM: paddle.histc

docs/api/paddle/logaddexp_cn.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
logaddexp
44
-------------------------------
55

6-
.. py:function:: paddle.logaddexp(x, y, name=None)
6+
.. py:function:: paddle.logaddexp(x, y, name=None, *, out=None)
77
88
计算 ``x`` 和 ``y`` 的以 e 为底的指数的和的自然对数。计算公式如下:
99

@@ -12,10 +12,14 @@ logaddexp
1212
1313
参数
1414
::::::::::
15-
- **x** (Tensor) - 输入的 Tensor,数据类型为:int32,int64,bfloat16,float16,float32、float64。
16-
- **y** (Tensor) - 输入的 Tensor,数据类型为:int32,int64,bfloat16,float16,float32、float64。
15+
- **x** (Tensor) - 输入的 Tensor,数据类型为:int32,int64,bfloat16,float16,float32、float64。别名 ``input``。
16+
- **y** (Tensor) - 输入的 Tensor,数据类型为:int32,int64,bfloat16,float16,float32、float64。别名 ``other``。
1717
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。
1818

19+
关键字参数
20+
::::::::::
21+
- **out** (Tensor,可选) - 输出 Tensor,若不为 ``None``,计算结果将保存在该 Tensor 中,默认值为 ``None``。
22+
1923
返回
2024
::::::::::
2125
``Tensor``,根据上述公式计算的 logaddexp(x) 结果

docs/api/paddle/logspace_cn.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
logspace
44
-------------------------------
55

6-
.. py:function:: paddle.logspace(start, stop, num, base=10.0, dtype=None, name=None)
6+
.. py:function:: paddle.logspace(start, stop, num, base=10.0, dtype=None, name=None, *, out=None)
77
88
返回一个 Tensor,Tensor 的值为在区间 :math:`[base^{start}, base^{stop}]` 上按对数均匀间隔的 :math:`num` 个值,输出 Tensor 的长度为 num。
99

@@ -14,12 +14,17 @@ logspace
1414
::::::::::::
1515

1616
- **start** (int|float|Tensor) – ``start`` 是区间开始值以 ``base`` 为底的指数,可以是一个标量,或是一个 shape 为 [] 的 0-D Tensor,该 Tensor 的数据类型可以是 float32、float64、int32 或者 int64。
17-
- **stop** (int|float|Tensor) – ``stop`` 是区间结束值以 ``base`` 为底的指数,可以是一个标量,或是一个 shape 为 [] 的 0-D Tensor,该 Tensor 的数据类型可以是 float32、float64、int32 或者 int64。
18-
- **num** (int|Tensor) – ``num`` 是给定区间内需要划分的区间数,可以是一个整型标量,或是一个 shape 为 [] 的 0-D Tensor,该 Tensor 的数据类型需为 int32。
17+
- **stop** (int|float|Tensor) – ``stop`` 是区间结束值以 ``base`` 为底的指数,可以是一个标量,或是一个 shape 为 [] 的 0-D Tensor,该 Tensor 的数据类型可以是 float32、float64、int32 或者 int64。别名 ``end``。
18+
- **num** (int|Tensor) – ``num`` 是给定区间内需要划分的区间数,可以是一个整型标量,或是一个 shape 为 [] 的 0-D Tensor,该 Tensor 的数据类型需为 int32。别名 ``steps``。
1919
- **base** (int|float|Tensor) – ``base`` 是对数函数的底数,可以是一个标量,或是一个 shape 为 [] 的 0-D Tensor,该 Tensor 的数据类型可以是 float32、float64、int32 或者 int64。
2020
- **dtype** (str|paddle.dtype|np.dtype,可选) – 输出 Tensor 的数据类型,可以是 float32、float64、int32 或者 int64。如果 dtype 的数据类型为 None,输出 Tensor 数据类型为 float32。
2121
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。
2222

23+
关键字参数
24+
::::::::::::
25+
- **out** (Tensor,可选) - 输出 Tensor,若不为 ``None``,计算结果将保存在该 Tensor 中,默认值为 ``None``。
26+
- **device** (str|Place,可选) - 输出 Tensor 的设备位置,可以为字符串或 Place 对象。默认值为 None,表示使用当前设备。
27+
- **requires_grad** (bool,可选) - 是否计算梯度。默认值为 False。
2328

2429
返回
2530
::::::::::::

docs/api/paddle/moveaxis_cn.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ moveaxis
1313
:width: 600
1414
参数
1515
:::::::::
16-
- **x** (Tensor) - 输入的 N-D Tensor,数据类型为:bool、int32、int64、float32、float64、complex64、complex128。
16+
- **x** (Tensor) - 输入的 N-D Tensor,数据类型为:bool、int32、int64、float32、float64、complex64、complex128。别名 ``input``。
1717
- **source** (int|tuple|list) - 将被移动的轴的位置,其每个元素必须为不同的整数。
1818
- **destination** (int|tuple|list) - 轴被移动后的目标位置,其每个元素必须为不同的整数。
1919
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。

0 commit comments

Comments
 (0)