-
Notifications
You must be signed in to change notification settings - Fork 5.9k
为median添加内核 #74767
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
为median添加内核 #74767
Conversation
|
你的PR提交成功,感谢你对开源项目的贡献! |
Codecov Report❌ Patch coverage is ❌ Your patch status has failed because the patch coverage (84.93%) 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 #74767 +/- ##
==========================================
Coverage ? 84.98%
==========================================
Files ? 7
Lines ? 333
Branches ? 0
==========================================
Hits ? 283
Misses ? 50
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
PR Category
Operator Mechanism
PR Types
Bug fixes
Description
pr目的:为median nanmedian反向添加均分
返回索引的情况:
均分的情况:
设计思路
1.仿照nanmeidan为median添加kernel
2. cpu反向添加均分:遍历得到相同值 进行存储 在进行均分 如果是avg 会找不到相同值 则单独处理 赋予梯度
2. Gpu反向添加均分:如果是avg 将选取的两个值都改为中位数的值 再使用ReduceCudaAMaxAMinGrad计算均分
由于增加均分 性能有所下降
代码改动
测试结果
PAddleAPITest下所有测试通过

在大tensor下存在索引不同的情况,相关误差来自于topk的索引误差

均分情况

另:paddle的topk与torch在nan上的逻辑并未对齐 torch会将nan作为最大值参与排序 但是paddle会出现nan和inf等莫名错误,后续看是否有修复计划