Skip to content

Conversation

@zhwesky2010
Copy link
Contributor

@zhwesky2010 zhwesky2010 commented Aug 8, 2025

PR Category

User Experience

PR Types

Improvements

Description

Pcard-73362

新增了 可变参数*size 用法适配的装饰器,适用于 paddle.ones/emtpy/zeros/... 等创建类API,以下用法全部适用:

# 兼容Pytorch新增用法 paddle.ones(1, dtype=paddle.float32) paddle.ones(1, 2, 3, dtype=paddle.float32) paddle.ones([1, 2, 3], dtype=paddle.float32) paddle.ones(size=[1, 2, 3], dtype=paddle.float32) # 原Paddle用法 paddle.ones([1, 2, 3], paddle.float32) paddle.ones(shape=[1, 2, 3], dtype=paddle.float32) 

装饰器编写方式

继承装饰器基类 DecoratorBase,根据该API的自身逻辑,灵活处理args、kwargs,注意装饰器逻辑必须是兼容升级的,即既要兼容Pytorch的新增用法,也要保留原Paddle的用法

@paddle-bot
Copy link

paddle-bot bot commented Aug 8, 2025

你的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.

@zhwesky2010 zhwesky2010 force-pushed the sizedecrator branch 2 times, most recently from 66c73c3 to 7037807 Compare August 8, 2025 11:10
@zhwesky2010 zhwesky2010 changed the title paddle.ones support more usage decrator for paddle.ones to support *size usage Aug 8, 2025
@zhwesky2010 zhwesky2010 changed the title decrator for paddle.ones to support *size usage Decrator for paddle.ones to support *size usage Aug 8, 2025
zhangbo9674
zhangbo9674 previously approved these changes Aug 8, 2025
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (develop@239dff3). Learn more about missing BASE report.

Additional details and impacted files
@@ Coverage Diff @@ ## develop #74494 +/- ## =========================================== Coverage ? 100.00% =========================================== Files ? 2 Lines ? 16 Branches ? 0 =========================================== Hits ? 16 Misses ? 0 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 merged commit 2d2476e into PaddlePaddle:develop Aug 11, 2025
57 checks passed
Enigmatisms pushed a commit to Enigmatisms/Paddle that referenced this pull request Aug 11, 2025
Enigmatisms pushed a commit to Enigmatisms/Paddle that referenced this pull request Aug 11, 2025
maxiaolong001 pushed a commit to maxiaolong001/Paddle that referenced this pull request Aug 12, 2025
Enigmatisms pushed a commit to Enigmatisms/Paddle that referenced this pull request Aug 14, 2025
Enigmatisms pushed a commit to Enigmatisms/Paddle that referenced this pull request Aug 19, 2025
Enigmatisms pushed a commit to Enigmatisms/Paddle that referenced this pull request Aug 20, 2025
Enigmatisms pushed a commit to Enigmatisms/Paddle that referenced this pull request Aug 21, 2025
zhangbo9674 pushed a commit that referenced this pull request Aug 25, 2025
…th_index) (#74547) * [API-Compat] paddle.compat.split is added and tested * [API-Compat] paddle.compat.split is rigorously tested * [API-Compat] Make the forbid_keywords decorator transparent * [API-Compat] Fixed decorator str input * [API-Compat] More unittest & static graph check & updated decorator * [API-Compat] Add paddle.compat.min/max and new PHI kernel (min/max_with_index) * [API-Compat] Add compat.min/max EN doc Attempting to fix integral type gradient computation (rejection) * [WIP][API-Compat] Add dyna-graph unittests for min/max * [WIP][API-Compat] Fixed CPU failure * [API-Compat] Correct min/max_with index gradient behavior * [API-Compat] XPU fix (attempt) * [API-Compat] Updated ForbidKeywordsDecorator * some create api support more usage (#74494) * [API-Compat] Static Graph and CPU end debug * [API-Compat] Resolved conflicts in decorator_utils.py * [API-Compat] Added static graph min/max_with_index op check, simplified implementation * [API-Compat] min/max static graph op test and out tensor support * [API-Compat] Resolved merge conflicts. * [API-Compat] Fixed CPU static graph bugs removed split API for independence. * [API-Compat] Resolved merged conflicts, add symbolic shape test. * [API-Compat] Updated unittests * [API-Compat] Update version year * [API-Compat] Fixed min/max out mechanism * [API-Compat] Try adding even more unittests. --------- Co-authored-by: zhwesky2010 <1183042833@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants