Skip to content

[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

Closed
zhwesky2010 wants to merge 3 commits into
PaddlePaddle:developfrom
zhwesky2010:claude

Conversation

@zhwesky2010

@zhwesky2010 zhwesky2010 commented May 12, 2026

Copy link
Copy Markdown
Contributor

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

是否引起精度变化

@paddle-bot

paddle-bot Bot commented May 12, 2026

Copy link
Copy Markdown

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.48649% with 10 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@1e8221d). Learn more about missing BASE report.

Files with missing lines Patch % Lines
python/paddle/tensor/creation.py 53.84% 6 Missing ⚠️
python/paddle/tensor/math.py 91.11% 4 Missing ⚠️

❌ 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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zhwesky2010 zhwesky2010 changed the title [API Compatibility] sgn/signbit/take/tensordot/vander/logaddexp/logspace/moveaxis/nan_to_num/nanmean/nansum/slice_scatter Edit By AI Agent [API Compatibility] select_scatter/sgn/signbit/slice_scatter/take/tensordot/tril_indices/triu_indices/vander/logaddexp/logspace/moveaxis/nan_to_num/nanmean/nansum/masked_fill Edit By AI Agent May 19, 2026
@zhwesky2010 zhwesky2010 changed the title [API Compatibility] select_scatter/sgn/signbit/slice_scatter/take/tensordot/tril_indices/triu_indices/vander/logaddexp/logspace/moveaxis/nan_to_num/nanmean/nansum/masked_fill Edit By AI Agent [API Compatibility] addmv/addr/fix/trunc/histc/special.round/... Edit By AI Agent May 25, 2026
@zhwesky2010 zhwesky2010 changed the title [API Compatibility] addmv/addr/fix/trunc/histc/special.round/... Edit By AI Agent [API Compatibility] index_copy_ Edit By AI Agent May 25, 2026
PaddlePaddle-bot

This comment was marked as outdated.

@zhwesky2010 zhwesky2010 changed the title [API Compatibility] index_copy_ Edit By AI Agent [API Compatibility] addmv/addr/fix/trunc/histc/special.round/... Edit By AI Agent May 26, 2026
zhwesky2010 and others added 3 commits June 1, 2026 12:05
…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 PaddlePaddle-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 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.pytest/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_decoratorNone 值的处理以提升 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):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 建议 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=Nonestarts=[0]end=Noneends=[sys.maxsize])。

@zhwesky2010 zhwesky2010 changed the title [API Compatibility] addmv/addr/fix/trunc/histc/special.round/... Edit By AI Agent [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 Jun 1, 2026
@PaddlePaddle-bot

Copy link
Copy Markdown

🤖 Paddle-CI-Agent | ci_status_monitor | 2026-06-01 20:48:08

CI报告基于以下代码生成(30分钟更新一次):
PR commit: 288bd27 | Merge base: 057b98f (branch: develop)


1 Required任务 : 1/1 通过

总执行(rerun次数) 总任务 ✅ 通过 ❌ 失败 ⏳ 运行中 ⏸️ 等待中 跳过
1(0) 1 1 0 0 0 0
任务 错误类型 置信度 日志

2 失败详情

@zhwesky2010 zhwesky2010 closed this Jun 1, 2026
@zhwesky2010

Copy link
Copy Markdown
Contributor Author

本PR迁移到 #79215

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.

3 participants