Skip to content

Commit ead4f14

Browse files
authored
[API compatibility] Added aliases for: is_floating_point, is_tensor, isin. And Updated docs. (PaddlePaddle#7415)
* [API compatibility] torch.as_tensor, torch.finfo, torch.is_complex, torch.nn.functional.pad * fix * fix codestyle * [API compatibility] is_floating_point, is_tensor, isin
1 parent ed19196 commit ead4f14

File tree

7 files changed

+17
-12
lines changed

7 files changed

+17
-12
lines changed

docs/api/paddle/finfo_cn.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ finfo
1717

1818
参数
1919
:::::::::
20-
- **dtype** (str|paddle.dtype|np.dtype,可选) - 输入的数据类型,可以是:paddle.float16、 paddle.float32、 paddle.float64、 paddle.bfloat16、 paddle.complex64、 paddle.complex128 或这些类型的字符串形式。
21-
- **type** - ``dtype`` 的别名,行为完全一致。
20+
- **dtype** (str|paddle.dtype|np.dtype,可选) - 输入的数据类型,可以是:paddle.float16、 paddle.float32、 paddle.float64、 paddle.bfloat16、 paddle.complex64、 paddle.complex128 或这些类型的字符串形式。别名: ``type``。
2221

2322
返回
2423
:::::::::

docs/api/paddle/is_complex_cn.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ is_complex
1212

1313
参数
1414
:::::::::
15-
- **x** (Tensor) - 输入 Tensor
16-
- **input** - ``x`` 的别名,行为完全一致。
15+
- **x** (Tensor) - 输入 Tensor。别名: ``input``。
1716

1817

1918
返回

docs/api/paddle/is_floating_point_cn.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@ is_floating_point
66
.. py:function:: paddle.is_floating_point(x)
77
判断输入 Tensor 的数据类型是否为浮点类型。
88

9+
.. note::
10+
别名支持: 参数名 ``input`` 可替代 ``x``,如 ``is_floating_point(input=tensor_x)`` 等价于 ``is_floating_point(x=tensor_x)`` 。
11+
912
参数
1013
:::::::::
1114

12-
- **x** (Tensor) - 输入的 Tensor。
15+
- **x** (Tensor) - 输入的 Tensor。别名: ``input``。
1316

1417
返回
1518
:::::::::

docs/api/paddle/is_tensor_cn.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ is_tensor
77
88
测试输入对象是否是 `paddle.Tensor`
99

10+
.. note::
11+
别名支持: 参数名 ``obj`` 可替代 ``x``,如 ``is_tensor(obj=tensor_x)`` 等价于 ``is_tensor(x=tensor_x)`` 。
12+
1013
参数
1114
::::::::::::
1215

13-
- **x** (Object) - 测试的对象。
16+
- **x** (Object) - 测试的对象。别名: ``obj``。
1417

1518

1619
返回

docs/api/paddle/isin_cn.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ isin
77
88
检验 ``x`` 中的每一个元素是否在 ``test_x`` 中。
99

10+
.. note::
11+
别名支持: 参数名 ``elements`` 可替代 ``x``,参数名 ``test_elements`` 可替代 ``test_x``,如 ``isin(elements=tensor1, test_elements=tensor2)`` 等价于 ``isin(x=tensor1, test_x=tensor2)`` 。
12+
1013
参数
1114
:::::::::
12-
- **x** (Tensor) - 输入的 tensor,数据类型为:'bfloat16', 'float16', 'float32', 'float64', 'int32', 'int64'。
13-
- **test_x** (Tensor) - 用于检验的 tensor,数据类型为:'bfloat16', 'float16', 'float32', 'float64', 'int32', 'int64'。
15+
- **x** (Tensor) - 输入的 tensor,数据类型为:'bfloat16', 'float16', 'float32', 'float64', 'int32', 'int64'。别名: ``elements``。
16+
- **test_x** (Tensor) - 用于检验的 tensor,数据类型为:'bfloat16', 'float16', 'float32', 'float64', 'int32', 'int64'。别名: ``test_elements``。
1417
- **assume_unique** (bool,可选) - 如果设置为 True,表示 ``x`` 与 ``test_x`` 的元素均是唯一的,这种情况可以提升计算的速度。默认值为 False。
1518
- **invert** (bool,可选) - 是否输出反转的结果。如果为 True,表示将结果反转。默认值为 False。
1619
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。

docs/api/paddle/nn/functional/pad_cn.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ pad
2626
参数
2727
::::::::::::
2828

29-
- **x** (Tensor) - Tensor,format 可以为 ``'NCL'``、``'NLC'``、``'NCHW'``、``'NHWC'``、``'NCDHW'`` 或 ``'NDHWC'``,默认值为 ``'NCHW'``,数据类型支持 float16、float32、float64、int32、int64、complex64、complex128。
30-
- **input** - ``x`` 的别名,行为完全一致。
29+
- **x** (Tensor) - Tensor,format 可以为 ``'NCL'``、``'NLC'``、``'NCHW'``、``'NHWC'``、``'NCDHW'`` 或 ``'NDHWC'``,默认值为 ``'NCHW'``,数据类型支持 float16、float32、float64、int32、int64、complex64、complex128。别名: ``input``。
3130
- **pad** (Tensor|list[int]|tuple[int]) - 填充大小,基本数据类型是整数类型。具体设置请参照 Note(注解)。
3231

3332
- **mode** (str,可选) - padding 的四种模式,分别为 ``'constant'``、``'reflect'``、``'replicate'`` 和 ``'circular'``,

docs/api/paddle/to_tensor_cn.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ to_tensor
3131
- **data** (scalar|tuple|list|ndarray|Tensor) - 初始化 Tensor 的数据,可以是 scalar,list,tuple,numpy\.ndarray,paddle\.Tensor 类型。
3232
- **dtype** (str|paddle.dtype|np.dtype,可选) - 创建 Tensor 的数据类型,可以是 bool、float16、float32、float64、int8、int16、int32、int64、uint8、complex64、complex128。
3333
默认值为 None,如果 ``data`` 为 python 浮点类型,则从 :ref:`cn_api_paddle_get_default_dtype` 获取类型,如果 ``data`` 为其他类型,则会自动推导类型。
34-
- **place** (CPUPlace|CUDAPinnedPlace|CUDAPlace,可选) - 创建 tensor 的设备位置,可以是 CPUPlace、CUDAPinnedPlace、CUDAPlace。默认值为 None,使用全局的 place。
35-
- **device** - ``place`` 的别名,行为完全一致。
34+
- **place** (CPUPlace|CUDAPinnedPlace|CUDAPlace,可选) - 创建 tensor 的设备位置,可以是 CPUPlace、CUDAPinnedPlace、CUDAPlace。默认值为 None,使用全局的 place。别名: ``device``。
3635
- **stop_gradient** (bool,可选) - 是否阻断 Autograd 的梯度传导。默认值为 True,此时不进行梯度传传导。
3736

3837
返回

0 commit comments

Comments
 (0)