Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
771c3b29
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 2 年 前同步成功
通知
2325
Star
20933
Fork
5424
代码
文件
提交
分支
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看板
未验证
提交
771c3b29
编写于
4月 18, 2020
作者:
L
Liufang Sang
提交者:
GitHub
4月 18, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update enhance error message for Initializer, smooth_l1 (#23912)
* update enhance error message test=develop * update details test=develop
上级
53fb0e92
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
33 addition
and
19 deletion
+33
-19
paddle/fluid/operators/gaussian_random_op.cc
paddle/fluid/operators/gaussian_random_op.cc
+6
-4
paddle/fluid/operators/smooth_l1_loss_op.cc
paddle/fluid/operators/smooth_l1_loss_op.cc
+27
-15
未找到文件。
paddle/fluid/operators/gaussian_random_op.cc
浏览文件 @
771c3b29
...
@@ -58,10 +58,12 @@ class GaussianRandomOp : public framework::OperatorWithKernel {
...
@@ -58,10 +58,12 @@ class GaussianRandomOp : public framework::OperatorWithKernel {
for
(
auto
dim
:
shape
)
{
for
(
auto
dim
:
shape
)
{
temp
.
push_back
(
static_cast
<
int64_t
>
(
dim
));
temp
.
push_back
(
static_cast
<
int64_t
>
(
dim
));
}
}
PADDLE_ENFORCE_GT
(
shape
.
size
(),
0UL
,
PADDLE_ENFORCE_GT
(
shape
.
size
(),
0UL
,
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
"Attribute(shape) of GaussianRandomOp must be set "
"Attribute(shape) of GaussianRandomOp must be set "
"and shape.size() > 0."
));
"and shape.size() > 0, but reveived shape.size() is %d"
,
shape
.
size
()));
ctx
->
SetOutputDim
(
"Out"
,
framework
::
make_ddim
(
temp
));
ctx
->
SetOutputDim
(
"Out"
,
framework
::
make_ddim
(
temp
));
}
}
...
...
paddle/fluid/operators/smooth_l1_loss_op.cc
浏览文件 @
771c3b29
...
@@ -34,15 +34,18 @@ class SmoothL1LossOp : public framework::OperatorWithKernel {
...
@@ -34,15 +34,18 @@ class SmoothL1LossOp : public framework::OperatorWithKernel {
check
=
false
;
check
=
false
;
}
}
if
(
check
)
{
if
(
check
)
{
PADDLE_ENFORCE_EQ
(
x_dims
,
y_dims
,
PADDLE_ENFORCE_EQ
(
x_dims
,
y_dims
,
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
"Input(X) ans Input(Y) of SmoothL1LossOp should "
"Input(X) ans Input(Y) of SmoothL1LossOp should "
"have the same size"
));
"have the same size, but received X dim is %s, Y dim is %s"
,
x_dims
.
to_str
(),
y_dims
.
to_str
()));
}
}
PADDLE_ENFORCE_GE
(
x_dims
.
size
(),
2
,
PADDLE_ENFORCE_GE
(
x_dims
.
size
(),
2
,
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
"The tensor rank of Input(X) of SmoothL1LossOp "
"The tensor rank of Input(X) of SmoothL1LossOp "
"should not be less than 2."
));
"should not be less than 2, but received %d."
,
x_dims
.
size
()));
if
(
ctx
->
HasInput
(
"InsideWeight"
))
{
if
(
ctx
->
HasInput
(
"InsideWeight"
))
{
PADDLE_ENFORCE_EQ
(
ctx
->
HasInput
(
"OutsideWeight"
),
true
,
PADDLE_ENFORCE_EQ
(
ctx
->
HasInput
(
"OutsideWeight"
),
true
,
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
...
@@ -58,7 +61,9 @@ class SmoothL1LossOp : public framework::OperatorWithKernel {
...
@@ -58,7 +61,9 @@ class SmoothL1LossOp : public framework::OperatorWithKernel {
PADDLE_ENFORCE_EQ
(
x_dims
,
dims
,
PADDLE_ENFORCE_EQ
(
x_dims
,
dims
,
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
"Input(X) ans Input(InsideWeight) of "
"Input(X) ans Input(InsideWeight) of "
"SmoothL1LossOp should have the same size"
));
"SmoothL1LossOp should have the same size, but "
"received X dim is %s, InsideWeight dim is %s"
,
x_dims
.
to_str
(),
dims
.
to_str
()));
}
}
dims
=
ctx
->
GetInputDim
(
"OutsideWeight"
);
dims
=
ctx
->
GetInputDim
(
"OutsideWeight"
);
...
@@ -71,7 +76,9 @@ class SmoothL1LossOp : public framework::OperatorWithKernel {
...
@@ -71,7 +76,9 @@ class SmoothL1LossOp : public framework::OperatorWithKernel {
PADDLE_ENFORCE_EQ
(
x_dims
,
dims
,
PADDLE_ENFORCE_EQ
(
x_dims
,
dims
,
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
"Input(X) ans Input(OutsideWeight) of "
"Input(X) ans Input(OutsideWeight) of "
"SmoothL1LossOp should have the same size"
));
"SmoothL1LossOp should have the same size, but "
"received X dim is %s, OutsideWeight dim is %s"
,
x_dims
.
to_str
(),
dims
.
to_str
()));
}
}
}
}
...
@@ -145,18 +152,23 @@ class SmoothL1LossGradOp : public framework::OperatorWithKernel {
...
@@ -145,18 +152,23 @@ class SmoothL1LossGradOp : public framework::OperatorWithKernel {
auto
in_dims
=
ctx
->
GetInputDim
(
"Diff"
);
auto
in_dims
=
ctx
->
GetInputDim
(
"Diff"
);
auto
out_dims
=
ctx
->
GetInputDim
(
framework
::
GradVarName
(
"Out"
));
auto
out_dims
=
ctx
->
GetInputDim
(
framework
::
GradVarName
(
"Out"
));
PADDLE_ENFORCE_GE
(
out_dims
.
size
(),
2
,
PADDLE_ENFORCE_GE
(
out_dims
.
size
(),
2
,
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
"The tensor rank of Input(Out@Grad) should be 2."
));
"The tensor rank of Input(Out@Grad) should be 2, but received %d."
,
out_dims
.
size
()));
if
(
ctx
->
IsRuntime
())
{
if
(
ctx
->
IsRuntime
())
{
PADDLE_ENFORCE_EQ
(
out_dims
[
0
],
in_dims
[
0
],
PADDLE_ENFORCE_EQ
(
out_dims
[
0
],
in_dims
[
0
],
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
"The 1st dimension of Input(Out@Grad) must be "
"The 1st dimension of Input(Out@Grad) must be "
"same as input in SmoothL1LossGradOp."
));
"same as input in SmoothL1LossGradOp, but received %d and %d."
,
out_dims
[
0
],
in_dims
[
0
]));
PADDLE_ENFORCE_EQ
(
out_dims
[
1
],
1
,
PADDLE_ENFORCE_EQ
(
out_dims
[
1
],
1
,
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
"The 2nd dimension of Input(Out@Grad) must be 1 in "
"The 2nd dimension of Input(Out@Grad) must be 1 in "
"SmoothL1LossGradOp."
));
"SmoothL1LossGradOp, but received %d."
,
out_dims
[
1
]));
}
}
auto
x_grad_name
=
framework
::
GradVarName
(
"X"
);
auto
x_grad_name
=
framework
::
GradVarName
(
"X"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录