Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
17299b8d
P
Paddle
项目概览
Crayon鑫
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
17299b8d
编写于
12月 19, 2019
作者:
W
WangXi
提交者:
gongweibao
12月 19, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix batch_norm_grad infer shape=0 & add allreduce enforce shape, test=develop (#21801)
上级
a3a3558d
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
18 addition
and
6 deletion
+18
-6
paddle/fluid/framework/details/all_reduce_op_handle.cc
paddle/fluid/framework/details/all_reduce_op_handle.cc
+5
-0
paddle/fluid/operators/batch_norm_op.cc
paddle/fluid/operators/batch_norm_op.cc
+13
-6
未找到文件。
paddle/fluid/framework/details/all_reduce_op_handle.cc
浏览文件 @
17299b8d
...
@@ -84,6 +84,11 @@ void AllReduceOpHandle::AllReduceImpl(
...
@@ -84,6 +84,11 @@ void AllReduceOpHandle::AllReduceImpl(
if
(
i
==
0
)
{
if
(
i
==
0
)
{
numel
=
static_cast
<
int64_t
>
(
lod_tensor
.
numel
());
numel
=
static_cast
<
int64_t
>
(
lod_tensor
.
numel
());
// only enforce place0, we will enforce other palce numel == place0 numel
PADDLE_ENFORCE_GT
(
numel
,
0
,
platform
::
errors
::
InvalidArgument
(
"The numel of tensos=[%s] must > 0. But now numel=[%d]"
,
in_var_handles
[
i
]
->
name
(),
numel
));
dtype
=
lod_tensor
.
type
();
dtype
=
lod_tensor
.
type
();
is_gpu_place
=
platform
::
is_gpu_place
(
lod_tensor
.
place
());
is_gpu_place
=
platform
::
is_gpu_place
(
lod_tensor
.
place
());
}
}
...
...
paddle/fluid/operators/batch_norm_op.cc
浏览文件 @
17299b8d
...
@@ -444,11 +444,17 @@ void BatchNormGradOp::InferShape(framework::InferShapeContext *ctx) const {
...
@@ -444,11 +444,17 @@ void BatchNormGradOp::InferShape(framework::InferShapeContext *ctx) const {
// check output
// check output
PADDLE_ENFORCE
(
ctx
->
HasOutput
(
framework
::
GradVarName
(
"X"
)),
""
);
PADDLE_ENFORCE
(
ctx
->
HasOutput
(
framework
::
GradVarName
(
"X"
)),
""
);
if
(
ctx
->
HasOutput
(
framework
::
GradVarName
(
"Scale"
)))
{
PADDLE_ENFORCE
(
ctx
->
HasOutput
(
framework
::
GradVarName
(
"Bias"
)),
const
bool
has_scale_grad
=
ctx
->
HasOutput
(
framework
::
GradVarName
(
"Scale"
));
"Output(Scale@GRAD) and Output(Bias@GRAD) should not be "
const
bool
has_bias_grad
=
ctx
->
HasOutput
(
framework
::
GradVarName
(
"Bias"
));
"null at same time"
);
}
PADDLE_ENFORCE_EQ
((
has_scale_grad
==
has_bias_grad
),
true
,
platform
::
errors
::
InvalidArgument
(
"Output(Scale@GRAD) and Output(Bias@GRAD) must be null "
"or not be null at same time. But now, "
"has Scale@Grad=[%d], has Bias@GRAD=[%d]"
,
has_scale_grad
,
has_bias_grad
));
const
bool
use_global_stats
=
ctx
->
Attrs
().
Get
<
bool
>
(
"use_global_stats"
);
const
bool
use_global_stats
=
ctx
->
Attrs
().
Get
<
bool
>
(
"use_global_stats"
);
if
(
use_global_stats
)
{
if
(
use_global_stats
)
{
PADDLE_ENFORCE
(
!
ctx
->
Attrs
().
Get
<
bool
>
(
"use_mkldnn"
),
PADDLE_ENFORCE
(
!
ctx
->
Attrs
().
Get
<
bool
>
(
"use_mkldnn"
),
...
@@ -463,7 +469,8 @@ void BatchNormGradOp::InferShape(framework::InferShapeContext *ctx) const {
...
@@ -463,7 +469,8 @@ void BatchNormGradOp::InferShape(framework::InferShapeContext *ctx) const {
:
x_dims
[
x_dims
.
size
()
-
1
]);
:
x_dims
[
x_dims
.
size
()
-
1
]);
ctx
->
SetOutputDim
(
framework
::
GradVarName
(
"X"
),
x_dims
);
ctx
->
SetOutputDim
(
framework
::
GradVarName
(
"X"
),
x_dims
);
if
(
ctx
->
HasOutput
(
framework
::
GradVarName
(
"Scale"
)))
{
// has_scale_grad == has_bias_grad, judge has_scale_grad is enough
if
(
has_scale_grad
)
{
ctx
->
SetOutputDim
(
framework
::
GradVarName
(
"Scale"
),
{
C
});
ctx
->
SetOutputDim
(
framework
::
GradVarName
(
"Scale"
),
{
C
});
ctx
->
SetOutputDim
(
framework
::
GradVarName
(
"Bias"
),
{
C
});
ctx
->
SetOutputDim
(
framework
::
GradVarName
(
"Bias"
),
{
C
});
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录