Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
f218330e
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
f218330e
编写于
9月 16, 2021
作者:
Z
zhiboniu
提交者:
GitHub
9月 16, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix group_size = floor(C/groups) from ceil(C/groups); add groupnorm group divisible check (#35644)
上级
67a094b5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
13 addition
and
6 deletion
+13
-6
paddle/fluid/operators/group_norm_op.cc
paddle/fluid/operators/group_norm_op.cc
+6
-0
paddle/fluid/operators/group_norm_op.cu
paddle/fluid/operators/group_norm_op.cu
+3
-2
paddle/fluid/operators/group_norm_op.h
paddle/fluid/operators/group_norm_op.h
+4
-4
未找到文件。
paddle/fluid/operators/group_norm_op.cc
浏览文件 @
f218330e
...
...
@@ -66,6 +66,12 @@ class GroupNormOp : public framework::OperatorWithKernel {
"The Attr(groups) of Op(group_norm) must be "
"greater than or equal to 1. But received: groups is [%s]."
,
groups
));
PADDLE_ENFORCE_EQ
(
channel_num
%
groups
,
0
,
platform
::
errors
::
InvalidArgument
(
"Expected number of channels in input to be divisible by "
"num_groups, but got input channel is %d and num_groups is %d"
,
channel_num
,
groups
));
if
(
ctx
->
HasInput
(
"Scale"
))
{
PADDLE_ENFORCE_EQ
(
...
...
paddle/fluid/operators/group_norm_op.cu
浏览文件 @
f218330e
...
...
@@ -144,7 +144,8 @@ class GroupNormKernel<platform::CUDADeviceContext, T>
const
int
C
=
(
data_layout
==
DataLayout
::
kNCHW
?
x_dims
[
1
]
:
x_dims
[
x_dims
.
size
()
-
1
]);
const
int
group_size
=
(
C
-
1
)
/
groups
+
1
;
const
int
group_size
=
C
/
groups
;
const
int
W
=
(
data_layout
==
DataLayout
::
kNCHW
?
x_dims
[
x_dims
.
size
()
-
1
]
:
x_dims
[
x_dims
.
size
()
-
2
]);
...
...
@@ -314,7 +315,7 @@ class GroupNormGradKernel<platform::CUDADeviceContext, T>
const
int
C
=
(
data_layout
==
DataLayout
::
kNCHW
?
x_dims
[
1
]
:
x_dims
[
x_dims
.
size
()
-
1
]);
const
int
group_size
=
(
C
-
1
)
/
groups
+
1
;
const
int
group_size
=
C
/
groups
;
const
int
W
=
(
data_layout
==
DataLayout
::
kNCHW
?
x_dims
[
x_dims
.
size
()
-
1
]
:
x_dims
[
x_dims
.
size
()
-
2
]);
...
...
paddle/fluid/operators/group_norm_op.h
浏览文件 @
f218330e
...
...
@@ -52,7 +52,7 @@ class GroupNormKernel : public framework::OpKernel<T> {
const
int
C
=
(
data_layout
==
DataLayout
::
kNCHW
?
x_dims
[
1
]
:
x_dims
[
x_dims
.
size
()
-
1
]);
const
int
group_size
=
(
C
-
1
)
/
groups
+
1
;
const
int
group_size
=
C
/
groups
;
y
->
mutable_data
<
T
>
(
ctx
.
GetPlace
());
mean
->
mutable_data
<
T
>
(
ctx
.
GetPlace
());
...
...
@@ -100,7 +100,7 @@ class GroupNormKernel : public framework::OpKernel<T> {
int
imid
;
for
(
imid
=
0
;
imid
<
imsize
-
(
imsize
%
M
);
imid
+=
M
,
iter_x_data
+=
M
)
{
// TODO(gaoxiang)
:
Because AVX/AVX2/AVX512 can not directly used
// TODO(gaoxiang)
:
Because AVX/AVX2/AVX512 can not directly used
// in template class/function, before we complete high
// performance cpu vector extension, temporarily unrolling
// loop to get high precision and performance
...
...
@@ -138,7 +138,7 @@ class GroupNormKernel : public framework::OpKernel<T> {
int
imid
;
for
(
imid
=
0
;
imid
<
imsize
-
(
imsize
%
M
);
imid
+=
M
,
iter_x_data
+=
M
*
C
)
{
// TODO(gaoxiang)
:
Because AVX/AVX2/AVX512 can not directly used
// TODO(gaoxiang)
:
Because AVX/AVX2/AVX512 can not directly used
// in template class/function, before we complete high
// performance cpu vector extension, temporarily unrolling
// loop to get high precision and performance
...
...
@@ -236,7 +236,7 @@ class GroupNormGradKernel : public framework::OpKernel<T> {
const
int
C
=
(
data_layout
==
DataLayout
::
kNCHW
?
x_dims
[
1
]
:
x_dims
[
x_dims
.
size
()
-
1
]);
const
int
group_size
=
(
C
-
1
)
/
groups
+
1
;
const
int
group_size
=
C
/
groups
;
d_x
->
mutable_data
<
T
>
(
ctx
.
GetPlace
());
math
::
SetConstant
<
DeviceContext
,
T
>
set_zero
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录