Skip to content

[API Compatibility] Update and add cn docs for aligned 19 apis -part#7893

Open
Manfredss wants to merge 3 commits intoPaddlePaddle:developfrom
Manfredss:Api_Compat
Open

[API Compatibility] Update and add cn docs for aligned 19 apis -part#7893
Manfredss wants to merge 3 commits intoPaddlePaddle:developfrom
Manfredss:Api_Compat

Conversation

@Manfredss
Copy link
Copy Markdown
Contributor

Apis:

paddle._assert
paddle.logit
paddle.mm
paddle.unique
paddle.lerp
paddle.allclose
paddle.tan
paddle.deg2rad
paddle.square
paddle.randint
paddle.inverse
paddle.nn.functional.leaky_relu
paddle.nn.functional.relu
paddle.nn.functional.pixel_shuffle
paddle.nn.ParameterDict
paddle.nn.Layer.to
paddle.nn.Layer.train
paddle.nn.functional.interpolate
paddle.amp.GradScaler

Copilot AI review requested due to automatic review settings April 14, 2026 01:06
@paddle-bot
Copy link
Copy Markdown

paddle-bot bot commented Apr 14, 2026

感谢你贡献飞桨文档,文档预览构建中,Docs-New 跑完后即可预览,预览链接:http://preview-pr-7893.paddle-docs-preview.paddlepaddle.org.cn/documentation/docs/zh/api/index_cn.html
预览工具的更多说明,请参考:飞桨文档预览工具

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 14, 2026

📚 本次 PR 文档预览链接(点击展开)
ℹ️ 预览提醒
请等待 Docs-NEW 流水线运行完成后再点击预览链接,否则可能会看到旧版本内容或遇到链接无法访问的情况。

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

该 PR 旨在对齐 Paddle 与 PyTorch/新版接口签名,更新并新增一批中文 API 文档(共 19 个 API),补充参数别名、关键字参数(如 out)、以及新增缺失 API 的中文页面,并在 API 总览中补充入口。

Changes:

  • 更新多份中文 API 文档签名与参数说明:新增 out/inplace/sorted/别名等,并补充关键字参数小节。
  • 新增 paddle.inversepaddle._assert 的中文 API 文档页,并在 Overview_cn.rst 中补充引用入口。
  • 引入 .claude/settings.local.json(本地工具配置文件)。

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
docs/api/paddle/unique_cn.rst paddle.unique 增加 sorted 参数并补充别名说明。
docs/api/paddle/tan_cn.rst paddle.tan 更新签名(含 out)与 dtype/返回值说明。
docs/api/paddle/square_cn.rst paddle.square 更新 dtype 支持范围并补充 out
docs/api/paddle/randint_cn.rst paddle.randint 对齐关键字参数(out/device/pin_memory/requires_grad)与别名 size
docs/api/paddle/nn/functional/relu_cn.rst relu 增加 inplace 参数与 input 别名。
docs/api/paddle/nn/functional/pixel_shuffle_cn.rst pixel_shufflex 补充 input 别名。
docs/api/paddle/nn/functional/log_softmax_cn.rst log_softmax 增加 keyword-only out,并补充别名。
docs/api/paddle/nn/functional/leaky_relu_cn.rst leaky_relu 增加 inplace 参数与 input 别名。
docs/api/paddle/nn/functional/interpolate_cn.rst interpolate 增加“两种调用方式”说明,并补充 input 别名。
docs/api/paddle/nn/ParameterDict_cn.rst ParameterDict 参数补充别名 values
docs/api/paddle/nn/Layer_cn.rst Layer.train/Layer.to 对齐签名与补充调用方式说明。
docs/api/paddle/mm_cn.rst mm 增加 keyword-only out 并补充 dtype 范围。
docs/api/paddle/logit_cn.rst logit 增加 keyword-only out、扩展 dtype 并更新返回说明。
docs/api/paddle/lerp_cn.rst lerp 增加 keyword-only out 并补充别名。
docs/api/paddle/inverse_cn.rst 新增 paddle.inverse 中文 API 文档页。
docs/api/paddle/deg2rad_cn.rst deg2rad 增加 keyword-only out
docs/api/paddle/amp/GradScaler_cn.rst GradScaler 补充多种调用方式与参数别名说明。
docs/api/paddle/allclose_cn.rst allclose 补充参数别名(input/other)。
docs/api/paddle/_assert_cn.rst 新增 paddle._assert 中文 API 文档页。
docs/api/paddle/Overview_cn.rst 在总览中补充 inverse_assert 的引用入口。
.claude/settings.local.json 新增本地 Claude 配置文件(含权限配置)。

Comment thread docs/api/paddle/unique_cn.rst Outdated
- **axis** (int,可选) - 指定选取独有元素的轴。默认值为 None,将输入平铺为 1-D 的 Tensor 后再选取独有元素。
- **axis** (int,可选) - 指定选取独有元素的轴。默认值为 None,将输入平铺为 1-D 的 Tensor 后再选取独有元素。别名 ``dim``。
- **dtype** (str|paddle.dtype|np.dtype,可选) - 用于设置 ``index`` , ``inverse`` 或者 ``counts`` 的类型,应该为 int32 或者 int64。默认:int64。
- **sorted** (bool,可选) - 不影响返回结果,与 PyTorch 保持一致。默认值为 True。
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

sorted 参数说明为“不会影响返回结果”,但文档开头描述为“返回按升序排序后的独有元素”,容易让读者误以为 sorted=False 会改变排序行为。建议在 sorted 参数说明中补充“无论 sorted 取值如何,返回值始终按升序/字典序排序;该参数仅用于兼容 PyTorch 签名”。

Suggested change
- **sorted** (bool,可选) - 不影响返回结果,与 PyTorch 保持一致。默认值为 True。
- **sorted** (bool,可选) - 不影响返回结果。无论 ``sorted`` 取值如何,返回值始终按升序排序;当指定 ``axis`` 时,返回值始终按字典序排序。该参数仅用于兼容 PyTorch 签名。默认值为 True。

Copilot uses AI. Check for mistakes.
参数
:::::::::
- **x** (Tensor) - 当前算子的输入,其是一个形状为 ``[N, C, H, W]`` 的 4-D Tensor。其中 ``N`` 是 batch size, ``C`` 是通道数,``H`` 是输入特征的高度,``W`` 是输入特征的宽度。其数据类型为 float16,float32,float64。
- **x** (Tensor) - 当前算子的输入,其是一个形状为 ``[N, C, H, W]`` 的 4-D Tensor。其中 ``N`` 是 batch size, ``C`` 是通道数,``H`` 是输入特征的高度,``W`` 是输入特征的宽度。其数据类型为 float16,float32,float64。别名 ``input``。
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

该行是中文说明,但使用了英文逗号:batch size, ``C```。按中文文档规范建议改为中文标点(例如 batch size,``C```),避免中英文标点混用。

Suggested change
- **x** (Tensor) - 当前算子的输入,其是一个形状为 ``[N, C, H, W]`` 的 4-D Tensor。其中 ``N`` 是 batch size, ``C`` 是通道数,``H`` 是输入特征的高度,``W`` 是输入特征的宽度。其数据类型为 float16,float32,float64。别名 ``input``。
- **x** (Tensor) - 当前算子的输入,其是一个形状为 ``[N, C, H, W]`` 的 4-D Tensor。其中 ``N`` 是 batch size``C`` 是通道数,``H`` 是输入特征的高度,``W`` 是输入特征的宽度。其数据类型为 float16,float32,float64。别名 ``input``。

Copilot uses AI. Check for mistakes.
Comment thread docs/api/paddle/nn/Layer_cn.rst Outdated

**返回**
Layer (返回网络层), self (返回自身)
Layerself
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

train() 小节的返回值从“Layer (返回网络层), self (返回自身)”改为“Layer,self”,与同文件其他方法返回值的表述格式不一致,且缺少对 self 含义的说明。建议统一为现有风格(明确返回 self,并说明其含义)。

Suggested change
Layerself
Layer (返回网络层), self (返回自身)

Copilot uses AI. Check for mistakes.
Comment thread docs/api/paddle/nn/Layer_cn.rst Outdated
Comment on lines +433 to +460
to(device=None, dtype=None, blocking=True)
'''''''''

根据给定的 device、dtype 和 blocking 转换 Layer 中的 parameters 和 buffers。
移动和/或转换 parameters 和 buffers。

本 API 支持三种调用方式:

1. ``to(device=None, dtype=None, blocking=True, *, non_blocking=False)``:
移动和/或转换 parameters 和 buffers。

2. ``to(dtype, blocking=True, *, non_blocking=False)``:
等价于 ``self.to(device=None, dtype=dtype, ...)``。

3. ``to(tensor, blocking=True, *, non_blocking=False)``:
等价于 ``self.to(device=tensor.place, dtype=tensor.dtype, ...)``。

.. note::
此方法为就地(in-place)操作。

**参数**

- **device** (str|paddle.CPUPlace()|paddle.CUDAPlace()|paddle.CUDAPinnedPlace()|paddle.XPUPlace()|None,可选) - 希望存储 Layer 的设备位置。如果为 None,设备位置和原始的 Tensor 的设备位置一致。如果设备位置是 string 类型,取值可为 ``cpu``, ``gpu:x`` and ``xpu:x``,这里的 ``x`` 是 GPUs 或者 XPUs 的编号。默认值:None。
- **dtype** (str|paddle.dtype|np.dtype,可选)- 数据的类型。如果为 None,数据类型和原始的 Tensor 一致。默认值:None。
- **blocking** (bool|None,可选)- 如果为 False 并且当前 Tensor 处于固定内存上,将会发生主机到设备端的异步拷贝。否则,会发生同步拷贝。如果为 None,blocking 会被设置为 True。默认为 False。
- **device** (str|paddle.CPUPlace()|paddle.CUDAPlace()|paddle.CUDAPinnedPlace()|paddle.XPUPlace()|None,可选) - 希望存储 Layer 的设备位置。如果为 None,设备位置和原始的 Tensor 的设备位置一致。如果设备位置是 string 类型,取值可为 ``cpu``, ``gpu:x`` 和 ``xpu:x``,这里的 ``x`` 是 GPUs 或者 XPUs 的编号。默认值:None。
- **dtype** (str|paddle.dtype|np.dtype|None,可选) - 数据的类型。如果为 None,数据类型和原始的 Tensor 一致。默认值:None。
- **blocking** (bool,可选)- 如果为 False 并且当前 Tensor 处于固定内存上,将会发生主机到设备端的异步拷贝。否则,会发生同步拷贝。默认值为 True。

**关键字参数**

- **non_blocking** (bool,可选) - 如果为 True 并且当前 Tensor 处于固定内存上,将会发生主机到设备端的异步拷贝。默认值为 False。``non_blocking`` 和 ``blocking`` 互斥,不能同时设置。
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

to(device=None, dtype=None, blocking=True) 这一节标题里的签名未体现后文描述的关键字参数 non_blocking(且前面列举的调用方式里也包含 *, non_blocking=False)。建议将小节标题签名与实际支持的参数保持一致(例如在标题中补充 *, non_blocking=False,或在标题处明确 non_blocking 为 keyword-only 参数),避免读者误以为该参数不可用。

Copilot uses AI. Check for mistakes.

2. ``interpolate(x, size, scale_factor, mode, align_corners, align_mode, data_format, recompute_scale_factor, name)``:
PaddlePaddle 原始的插值实现,详见以下文档。

Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

这里用 interpolate(input, ...)interpolate(x, ...) 区分两种“调用方式”,但同一段文档中 x 也被标注为别名 input,容易让读者误解为存在两个不同参数名/两个不同接口。建议在该段补一句说明:inputx 的别名(PyTorch 风格命名),两种调用方式仅是参数组合差异。

Suggested change
其中,``input`` 是 ``x`` 的别名(PyTorch 风格命名),上述两种写法仅用于区分不同的参数组合,并非表示存在两个不同的参数名或接口。

Copilot uses AI. Check for mistakes.
Comment thread .claude/settings.local.json Outdated
Comment on lines +1 to +9
{
"permissions": {
"allow": [
"WebFetch(domain:github.com)",
"Bash(gh api:*)",
"Bash(grep:*)"
]
}
}
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

新增的 .claude/settings.local.json 看起来是本地/个人环境配置文件(且包含允许 WebFetch、Bash 命令等权限配置)。这类 *.local.json 文件通常不应提交到仓库,以免影响他人环境或引入不必要的权限配置。建议将该文件从提交中移除,并在 .gitignore 中忽略 .claude/ 或至少忽略 settings.local.json;如确需共享配置,请改为提交不含本地权限的通用配置文件。

Suggested change
{
"permissions": {
"allow": [
"WebFetch(domain:github.com)",
"Bash(gh api:*)",
"Bash(grep:*)"
]
}
}
{}

Copilot uses AI. Check for mistakes.
Manfredss and others added 2 commits April 14, 2026 09:44
- unique_cn.rst: clarify sorted param always returns ascending order
- Layer_cn.rst: restore detailed train() return, add non_blocking to to() title
- interpolate_cn.rst: clarify input is alias for x in two calling styles
- pixel_shuffle_cn.rst: fix English comma to Chinese comma
- .gitignore: add .claude to prevent committing local settings
- Remove .claude/settings.local.json from tracking

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace COPY-FROM directives with inline code examples since the
CI nightly Paddle wheel does not include these new APIs yet.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants