-
Notifications
You must be signed in to change notification settings - Fork 5.8k
add groupnorm group divisible check #35644
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
Conversation
Thanks for your contribution! |
Describe 中详细描述下问题解决方案 和 解决后的结果 |
const int group_size = C / groups; | ||
|
||
PADDLE_ENFORCE_EQ( | ||
C, group_size * groups, | ||
platform::errors::InvalidArgument( | ||
"Expected number of channels in input to be divisible by " | ||
"num_groups, but got input channel is %d and num_groups=%d", | ||
C, groups)); | ||
|
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.
异常检查建议都加在 InferShape 中,避免不同设备的compute中都包含这些逻辑
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
const int group_size = C / groups; | ||
PADDLE_ENFORCE_EQ( | ||
C, group_size * groups, | ||
platform::errors::InvalidArgument( | ||
"Expected number of channels in input to be divisible by " | ||
"num_groups, but got input channel is %d and num_groups=%d", | ||
C, groups)); |
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.
异常检查建议都加在 InferShape 中,避免不同设备的compute中都包含这些逻辑
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
…roup divisible check
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
…roup divisible check (PaddlePaddle#35644)
PR types
Bug fixes
PR changes
APIs
Describe
add groupnorm group divisible check
修改内容:
1)修改group_size计算公式为: group_size = floor(C / groups),分组方式与行业惯例保持一致。
2)考虑groupnorm本意。添加channel_num能够被groups整除的检查。如果不能整除则会报错。
Log:
ValueError: (InvalidArgument) Expected number of channels in input to be divisible by num_groups, but got input channel is 6 and num_groups is 4
[Hint: Expected channel_num % groups == 0, but received channel_num % groups:2 != 0:0.] (at /home/niuzhibo/work/paddleapi/Paddle/paddle/fluid/operators/group_norm_op.cc:74)
[operator < group_norm > error]