-
Notifications
You must be signed in to change notification settings - Fork 884
Enhance validate_api_difference_format #7728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance validate_api_difference_format #7728
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 文档预览链接(点击展开)
|
There was a problem hiding this 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 增强了 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 | 调整参数映射表顺序 |
增强 validate_api_difference_format 工具,新增如下检查项:
并据此修改差异文档