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

fix bug to support dropout eval grad computing. #37305

Merged

Conversation

limin2021
Copy link
Contributor

@limin2021 limin2021 commented Nov 17, 2021

PR types

Bug fixes

PR changes

OPs

Describe

Question:
#35122 support dropout in eval mode (paddle2.0已经将eval和no_grad解绑,eval下做反向是合理的,竞品也都支持这个行为). But #35621 remove these modifications of #35122.
In this PR, we recover the modifications in #35122.

test code:
image

before this PR:
image

after this PR:
image

Copy link
Contributor

@wangxicoding wangxicoding left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@smallv0221 smallv0221 left a comment

Choose a reason for hiding this comment

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

LGTM

dX.device(place) = static_cast<T>(0) * dY;
if (is_test) {
if (dropout_implementation == "upscale_in_train") {
dX.device(place) = static_cast<T>(1) * dY;
Copy link
Contributor

Choose a reason for hiding this comment

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

是不是memcpy好一些

Copy link
Contributor Author

Choose a reason for hiding this comment

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

嗯嗯,该pr只用于恢复 #35122 的修改哈。后续可以进一步优化。

@MingMingShangTian MingMingShangTian merged commit c3d3001 into PaddlePaddle:develop Nov 18, 2021
limin2021 added a commit to limin2021/Paddle that referenced this pull request Nov 18, 2021
* fix bug to support dropout eval grad computing.

* Remove useless code.
lanxianghit pushed a commit that referenced this pull request Nov 22, 2021
fix bug to support dropout eval grad computing. cherry-pick #37305.
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.

4 participants