[API Compatibility] select_scatter/sgn/signbit/slice_scatter/tensordot/tril_indices/triu_indices/vander/logaddexp/logspace/moveaxis/nan_to_num/nanmean/nansum/masked_fill Edit By AI Agent#78971
Conversation
|
你的PR提交成功,感谢你对开源项目的贡献! |
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (86.48%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## develop #78971 +/- ##
==========================================
Coverage ? 86.48%
==========================================
Files ? 3
Lines ? 74
Branches ? 0
==========================================
Hits ? 64
Misses ? 10
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…t/tril_indices/triu_indices/vander/logaddexp/logspace/moveaxis/nan_to_num/nanmean/nansum/masked_fill Edit By AI Agent Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PaddlePaddle-bot
left a comment
There was a problem hiding this comment.
🤖 Paddle-CI-Agent | pr_review |
2026-06-01 20:41:34
📋 Review 摘要
PR 概述:为多个 Paddle API 添加 PyTorch 风格的参数别名兼容性支持(select_scatter、sgn、signbit、slice_scatter、tensordot、tril/triu_indices、vander、logaddexp、logspace、moveaxis、nan_to_num、nanmean、nansum、masked_fill 等)
变更范围:python/paddle/tensor/、python/paddle/utils/decorator_utils.py、test/legacy_test/
影响面 Tag:[User Experience]
问题
| 级别 | 文件 | 概述 |
|---|---|---|
| 🟡 建议 | python/paddle/utils/decorator_utils.py:1264 |
slice_scatter_decorator 仅处理 int 类型转 list,未处理 PyTorch 允许的 None 值(如 start=None) |
📝 PR 规范检查
符合规范。PR Category、PR Types、Description、是否引起精度变化四个必填 section 均存在且内容非空。标题格式 [API Compatibility] 与 diff 影响面一致。
总体评价
PR 整体实现规范,通过装饰器和手动 out 参数支持实现了 PyTorch API 兼容。测试覆盖了多种调用风格(位置参数、关键字参数、别名参数、Tensor 方法)。建议补充 slice_scatter_decorator 对 None 值的处理以提升 PyTorch 兼容度。
| # Convert int to list for dim/axes, start/starts, end/ends, step/strides | ||
| int_to_list_params = ['axes', 'starts', 'ends', 'strides'] | ||
| for param in int_to_list_params: | ||
| if param in kwargs and isinstance(kwargs[param], int): |
There was a problem hiding this comment.
🟡 建议 isinstance(kwargs[param], int) 仅将 int 类型转为 list,但 PyTorch 的 torch.slice_scatter 允许 start=None(表示从头开始)和 end=None(表示到末尾)。当用户传入 start=None 时,decorator 会将 starts=None 直接传给 slice_scatter,而该函数期望 list 类型,将导致运行时错误。
建议在 int-to-list 转换前增加对 None 的处理逻辑:
int_to_list_params = ['axes', 'starts', 'ends', 'strides']
for param in int_to_list_params:
if param in kwargs:
if isinstance(kwargs[param], int):
kwargs[param] = [kwargs[param]]
elif kwargs[param] is None:
del kwargs[param] # 让函数使用默认行为或后续逻辑处理或者根据 PyTorch 语义,将 None 转换为对应的默认值(如 start=None → starts=[0],end=None → ends=[sys.maxsize])。
|
本PR迁移到 #79215 |
PR Category
User Experience
PR Types
Improvements
Description
API Compatibility Edit By AI Agent:
torch.select_scatter
torch.sgn
torch.signbit
torch.slice_scatter
torch.tensordot
torch.tril_indices
torch.triu_indices
torch.vander
torch.logaddexp
torch.logspace
torch.moveaxis
torch.nan_to_num
torch.nanmean
torch.nansum
torch.masked_fill
是否引起精度变化
否