-
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
optimize group_norm op forward #39596
Conversation
Thanks for your contribution! |
cfaf487
to
58d7046
Compare
82f7c98
to
70304ac
Compare
70304ac
to
7f3c76b
Compare
@@ -96,16 +173,18 @@ __global__ void GroupNormForward(const T* x, const T* mean, const T* var, | |||
int H = imsize / W; | |||
int ccid = gid * group_size + cid; | |||
if (ccid >= C) return; | |||
T x_mean = mean[bid * groups + gid]; | |||
T x_var = var[bid * groups + gid]; | |||
auto ng = bid * groups + gid; |
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.
bid * groups + gid;
后续使用了三次,所以定义了一个变量保存,减少后续索引计算量
7098738
to
908f4e4
Compare
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
Performance optimization
PR changes
OPs
Describe
优化group_norm前向计算,性能数据如下: