Skip to content

Conversation

zhiboniu
Copy link
Contributor

@zhiboniu zhiboniu commented Sep 10, 2021

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]

@paddle-bot-old
Copy link

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

@jeff41404
Copy link
Contributor

Describe 中详细描述下问题解决方案 和 解决后的结果

Comment on lines 147 to 155
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));

Copy link
Contributor

Choose a reason for hiding this comment

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

异常检查建议都加在 InferShape 中,避免不同设备的compute中都包含这些逻辑

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

Comment on lines 55 to 61
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));
Copy link
Contributor

Choose a reason for hiding this comment

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

异常检查建议都加在 InferShape 中,避免不同设备的compute中都包含这些逻辑

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
Contributor

@jeff41404 jeff41404 left a comment

Choose a reason for hiding this comment

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

lgtm

@jeff41404 jeff41404 merged commit f218330 into PaddlePaddle:develop Sep 16, 2021
AnnaTrainingG pushed a commit to AnnaTrainingG/Paddle that referenced this pull request Sep 29, 2021
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.

2 participants