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 LayerNorm Problem #33420

Merged
merged 2 commits into from
Jun 12, 2021
Merged

Fix LayerNorm Problem #33420

merged 2 commits into from
Jun 12, 2021

Conversation

zhiboniu
Copy link
Contributor

@zhiboniu zhiboniu commented Jun 8, 2021

PR types

Bug fixes

PR changes

OPs

Describe

优化LayerNorm计算过程。
同时修复如下问题:
DLTP-25782 [Bug]
DLTP-26400 [Bug]

修复LayerNorm在大数输入时输出Nan的bug。
DLTP-28680 [Bug]

修复LayerNorm在归一化维度长度<kMaxBlockDim时的BlockDim计算错误bug。

修复LayerNorm在大输入shape时输出结果0的bug。

@paddle-bot-old
Copy link

paddle-bot-old bot commented Jun 8, 2021

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

@@ -952,7 +977,7 @@ class LayerNormGradKernel<platform::CUDADeviceContext, T>
const auto begin_norm_axis = ctx.Attr<int>("begin_norm_axis");
auto matrix_dim = framework::flatten_to_2d(x_dims, begin_norm_axis);
int batch_size = static_cast<int>(matrix_dim[0]);
Copy link
Contributor

Choose a reason for hiding this comment

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

batch_size是否也需要改成 int64_t

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Collaborator

@ZHUI ZHUI left a comment

Choose a reason for hiding this comment

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

建议文件权限仍然 改为 644

@@ -898,7 +923,7 @@ class LayerNormKernel<platform::CUDADeviceContext, T>

auto matrix_dim = framework::flatten_to_2d(x_dims, begin_norm_axis);
int batch_size = static_cast<int>(matrix_dim[0]);
Copy link
Contributor

Choose a reason for hiding this comment

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

batch_size是否也需要改成 int64_t

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -952,7 +977,7 @@ class LayerNormGradKernel<platform::CUDADeviceContext, T>
const auto begin_norm_axis = ctx.Attr<int>("begin_norm_axis");
auto matrix_dim = framework::flatten_to_2d(x_dims, begin_norm_axis);
int batch_size = static_cast<int>(matrix_dim[0]);
int feature_size = static_cast<int>(matrix_dim[1]);
int64_t feature_size = static_cast<int64_t>(matrix_dim[1]);

LayerNormBackward<T, U>(x_data, d_y_data, scale_data, mean_data, var_data,
Copy link
Contributor

Choose a reason for hiding this comment

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

本次主要对正向计算进行了优化,反向计算的优化也可以在未来考虑

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

@jeff41404
Copy link
Contributor

LGTM

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

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