Skip to content

Conversation

@cangtianhuang
Copy link
Contributor

@cangtianhuang cangtianhuang commented Jun 23, 2025

PR Category

Operator Mechanism

PR Types

Improvements

Description

The AddNKernel for paddle.add_n api on CPU (location: paddle/phi/kernels/cpu/add_n_kernel.cc) did not implement type promotion, resulting in accuracy diff compared to torch.

This pr resolves the issue by utilizing MPTypeTrait and temp_out for intermediate computations.

  • When types are promoted, temp_out is requested and finally casts back to the original type.
  • When types are consistent, in-place operation is retained.
  • Removes the old code for adding two tensors (failed to zero out in edge cases).

All paddle.add_n test cases pass in CPU mode on PaddleAPITest:
image

@paddle-bot
Copy link

paddle-bot bot commented Jun 23, 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.

@paddle-bot paddle-bot bot added the contributor External developers label Jun 23, 2025
@codecov-commenter
Copy link

codecov-commenter commented Jun 23, 2025

Codecov Report

❌ Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@9c1900c). Learn more about missing BASE report.

⚠️ Current head 6a5377e differs from pull request most recent head 66187eb

Please upload reports for the commit 66187eb to get more accurate results.

Files with missing lines Patch % Lines
paddle/phi/kernels/cpu/add_n_kernel.cc 91.66% 1 Missing ⚠️
Additional details and impacted files
@@ Coverage Diff @@ ## develop #73562 +/- ## ========================================== Coverage ? 91.66% ========================================== Files ? 1 Lines ? 12 Branches ? 0 ========================================== Hits ? 11 Misses ? 1 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.
Copy link
Contributor

@wanghuancoder wanghuancoder left a comment

Choose a reason for hiding this comment

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

LGTM 所有精度、大Tensor工作均需要书豪把把关。Coverage 9 可以找田硕豁免。

@wanghuancoder wanghuancoder merged commit 6247daa into PaddlePaddle:develop Jun 26, 2025
59 of 68 checks passed
@cangtianhuang cangtianhuang deleted the dev-fast branch June 30, 2025 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor External developers

4 participants