-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Fix LayerNorm Problem #33420
Conversation
Thanks for your contribution! |
…hile large data input
@@ -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]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
batch_size是否也需要改成 int64_t
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this 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]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
batch_size是否也需要改成 int64_t
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
本次主要对正向计算进行了优化,反向计算的优化也可以在未来考虑
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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。