Enhance validate_api_difference_format #7728
Merged
zhwesky2010 merged 4 commits intoPaddlePaddle:developfrom Feb 6, 2026
Merged
Enhance validate_api_difference_format #7728zhwesky2010 merged 4 commits intoPaddlePaddle:developfrom
zhwesky2010 merged 4 commits intoPaddlePaddle:developfrom
Conversation
…ation - Add `parse_parameters_from_signature` method to extract parameter names from API signatures - Add `extract_api_name_from_line` method to parse API names from markdown links - Extend `validate_remark_column` to validate parameter mapping against API signatures - Check that parameters in mapping tables exist in the actual API signatures - Verify that all parameters from the API signature are included in the mapping table - Add allowlist for commonly missing parameters (out, device, dtype) - Improve error messages with specific file paths and parameter details
|
感谢你贡献飞桨文档,文档预览构建中,Docs-New 跑完后即可预览,预览链接:http://preview-pr-7728.paddle-docs-preview.paddlepaddle.org.cn/documentation/docs/zh/api/index_cn.html |
📚 本次 PR 文档预览链接(点击展开)
|
Contributor
There was a problem hiding this comment.
Pull request overview
本 PR 增强了 validate_api_difference_format 工具,新增了三项检查功能,并据此修复了大量 API 差异文档。
Changes:
- 在验证工具中添加了参数签名解析功能,用于提取 PyTorch 和 Paddle API 的参数列表
- 实现了三项新的验证规则:参数名称必须在签名中、参数映射顺序必须与签名一致、Torch 的所有参数都应出现在映射表中
- 修复了 70+ 个 API 差异文档,调整参数映射表的顺序以匹配 API 签名顺序,修正了函数签名中的重复参数和缺失参数
Reviewed changes
Copilot reviewed 69 out of 69 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| validate_api_difference_format.py | 添加了参数解析和验证逻辑,新增 parse_parameters_from_signature 等辅助方法 |
| torch.signal.windows.exponential.md | 调整参数映射表顺序(sym 参数移至正确位置) |
| torch.set_printoptions.md | 调整参数映射表顺序(sci_mode 参数移至正确位置) |
| torch.round.md | 在 Paddle 签名中添加缺失的 decimals 参数 |
| torch.nn.functional.nll_loss.md | 调整参数映射表顺序(size_average 参数移至正确位置) |
| torch.nn.Module.register_forward_hook.md | 移除 always_call 参数中的默认值 =False |
| torch.nn.LayerNorm.md | 调整参数映射表顺序(eps 参数移至顶部) |
| torch.nansum.md | 修正参数名 keep_dim 为 keepdim |
| torch.load.md | 调整参数映射表顺序(mmap 和 **pickle_load_args 顺序) |
| torch.linalg.matrix_rank.md | 移除 PyTorch 签名中重复的 hermitian 参数 |
| torch.jit.script.md | 调整参数映射表顺序(_rcb 和 example_inputs 顺序) |
| flash_attn files (2 files) | 调整参数映射表顺序,修复 Paddle 签名中的中文逗号 |
| torch.distributions.distribution.Distribution.md | 修复 Paddle 签名中的中文顿号 |
| torch.autocast.md | 调整参数映射表顺序(enabled 和 dtype 顺序) |
| fairscale.nn.model_parallel.layers.ParallelEmbedding.md | 调整参数映射表顺序 |
| torch.nn.functional.pixel_shuffle.md | 修正参数名和描述 |
| torch.nn.LazyInstanceNorm* files (3 files) | 合并 weight_attr 和 bias_attr 到单行,调整参数顺序 |
| torch.nn.LazyBatchNorm* files (3 files) | 合并 weight_attr 和 bias_attr 到单行,调整参数顺序 |
| torchvision.datasets.VOCDetection.md | 调整参数映射表顺序(download 参数位置) |
| torch.sparse_coo_tensor.md | 调整参数映射表顺序(size 和 dtype 顺序) |
| torch.nn.functional.instance_norm.md | 添加 use_input_stats 参数,调整参数顺序 |
| torch.nn.functional.batch_norm.md | 调整参数映射表顺序(training, momentum, eps) |
| torch.nn.functional.avg_pool* files (2 files) | 调整参数映射表顺序 |
| torch.nn.SyncBatchNorm.md | 移除 track_running_stats 与 use_global_stats 的映射 |
| torch.nn.BatchNorm1d.md | 合并 affine 参数到 weight_attr/bias_attr |
| torch.Tensor.transpose_.md | 将 dim0 和 dim1 拆分为独立的行 |
| torch.Tensor.split.md | 调整参数映射表顺序 |
| torch.Tensor.diag.md | 移除 Paddle 签名中的 x 参数 |
| torchvision.models.* files (30+ files) | 调整参数映射表顺序(pretrained, progress, weights) |
| torch.optim.lr_scheduler.OneCycleLR.md | 将 total_steps/epochs/steps_per_epoch 拆分为独立的行 |
| torch.Tensor.std.md | 调整参数映射表顺序 |
zhwesky2010
reviewed
Feb 6, 2026
zhwesky2010
approved these changes
Feb 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
增强 validate_api_difference_format 工具,新增如下检查项:
并据此修改差异文档