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

Optimize the bce_loss op to avoid copy input back to CPU. #32265

Merged
merged 1 commit into from
Apr 14, 2021

Conversation

Xreki
Copy link
Contributor

@Xreki Xreki commented Apr 14, 2021

PR types

Performance optimization

PR changes

OPs

Describe

bce_loss OP要求输入数据每个元素的值在[0, 1]范围内,因此将输入数据从GPU拷贝到CPU上检查,比较低效。

优化方法:在CUDA Kernel中使用PADDLE_ENFORCE进行检查。

@paddle-bot-old
Copy link

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

@Xreki
Copy link
Contributor Author

Xreki commented Apr 14, 2021

2021-04-14 15:42:51 0. The error message you wrote in PADDLE_ENFORCE{**} or PADDLE_THROW does not meet our error message writing specification. Possible errors include 1. the error message is empty / 2. the error message is too short / 3. the error type is not specified. Please read the specification [ https://github.com/PaddlePaddle/Paddle/wiki/Paddle-Error-Message-Writing-Specification ], then refine the error message. If it is a mismatch, please request chenwhql (Recommend), luotao1 or lanxianghit review and approve.
2021-04-14 15:42:51 The PADDLE_ENFORCE{
**} or PADDLE_THROW entries that do not meet the specification are as follows:
2021-04-14 15:42:51 PADDLE_ENFORCE( + (x >= static_cast(0)) && (x <= one), + "Input is expected to be within the interval [0, 1], but recieved %f.", + x);
2021-04-14 15:42:51 There are 1 approved errors.

经确认,CUDA Kernel里面只能使用PADDLE_ENFORCE进行错误检查,且不能使用CPU端定义的error类型。

Copy link
Contributor

@chenwhql chenwhql left a comment

Choose a reason for hiding this comment

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

LGTM for PADDLE_ENFORCE

@Xreki Xreki merged commit 69d8027 into PaddlePaddle:develop Apr 14, 2021
@Xreki Xreki deleted the opt/bce branch April 14, 2021 14:09
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