Skip to content
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

improve group norm cpu precision and performance #33176

Merged
merged 2 commits into from
May 31, 2021

Conversation

jeff41404
Copy link
Contributor

@jeff41404 jeff41404 commented May 27, 2021

PR types

Performance optimization

PR changes

OPs

Describe

问题:paddle.nn.GroupNorm 在float32下CPU计算结果和准确值的相对误差大于e-5
原因:原有计算方法在计算均值和方差时为逐个数相加,当计算数据个数较多 且 累加数比较大 且 单个元素较小 时就容易造成舍入误差 从而导致 最终结果的误差
方案:使用SIMD的思想进行分组累加,最后再归并加和以降低舍入误差,并调研其它框架中的类似算法,均使用此种思想来实现。同时有个附加好处是增加了计算并行性,提升性能
效果:paddle.nn.GroupNorm 在float32下CPU计算结果和准确值的相对误差已经小于e-6,且性能提升7%

@paddle-bot-old
Copy link

paddle-bot-old bot commented May 27, 2021

✅ This PR's description meets the template requirements!
Please wait for other CI results.

@paddle-bot-old
Copy link

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

Copy link
Contributor

@XiaoguangHu01 XiaoguangHu01 left a comment

Choose a reason for hiding this comment

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

LGTM

@jeff41404 jeff41404 closed this May 31, 2021
@jeff41404 jeff41404 deleted the improve_group_norm branch May 31, 2021 03:24
@jeff41404 jeff41404 restored the improve_group_norm branch May 31, 2021 04:11
@jeff41404 jeff41404 reopened this May 31, 2021
@XiaoguangHu01 XiaoguangHu01 merged commit 0a9937d into PaddlePaddle:develop May 31, 2021
@jeff41404 jeff41404 deleted the improve_group_norm branch May 31, 2021 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants