Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
5f22478a
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看板
未验证
提交
5f22478a
编写于
4月 09, 2020
作者:
W
Wilber
提交者:
GitHub
4月 09, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
error message enhancement for repeated fc. test=develop (#23562)
error message enhancement for repeated fc
上级
a5bdf485
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
42 addition
and
20 deletion
+42
-20
paddle/fluid/operators/fused/fusion_repeated_fc_relu_op.cc
paddle/fluid/operators/fused/fusion_repeated_fc_relu_op.cc
+42
-20
未找到文件。
paddle/fluid/operators/fused/fusion_repeated_fc_relu_op.cc
浏览文件 @
5f22478a
...
...
@@ -22,37 +22,59 @@ namespace operators {
void
FusionRepeatedFCReluOp
::
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
{
PADDLE_ENFORCE
(
ctx
->
HasInput
(
"X"
),
"Input(X) of FusionRepeatedFCReluOp should not be null."
);
OP_INOUT_CHECK
(
ctx
->
HasInput
(
"X"
),
"Input"
,
"X"
,
"FusionRepeatedFCRelu"
);
auto
sz
=
ctx
->
Inputs
(
"W"
).
size
();
PADDLE_ENFORCE_GT
(
sz
,
1UL
,
"Inputs(W) of FusionRepeatedFCReluOp should larger than 1."
);
PADDLE_ENFORCE_EQ
(
ctx
->
Inputs
(
"Bias"
).
size
(),
sz
,
"Size of inputs(Bias) of FusionRepeatedFCReluOp should be "
"equal to inputs size."
);
PADDLE_ENFORCE_EQ
(
ctx
->
Outputs
(
"ReluOut"
).
size
(),
sz
-
1
,
"Size of output(ReluOut) of FusionRepeatedFCReluOp should "
"be equal to inputs size -1."
);
PADDLE_ENFORCE
(
ctx
->
HasOutput
(
"Out"
),
"Output(Out) of FusionRepeatedFCReluOp should not be null."
);
PADDLE_ENFORCE_GT
(
sz
,
1UL
,
platform
::
errors
::
InvalidArgument
(
"Inputs(W) of FusionRepeatedFCReluOp should "
"be greater than 1, but received value is %d."
,
sz
));
PADDLE_ENFORCE_EQ
(
ctx
->
Inputs
(
"Bias"
).
size
(),
sz
,
platform
::
errors
::
InvalidArgument
(
"Size of inputs(Bias) of FusionRepeatedFCReluOp should be "
"equal to inputs size %d, but received value is %d."
,
sz
,
ctx
->
Inputs
(
"Bias"
).
size
()));
PADDLE_ENFORCE_EQ
(
ctx
->
Outputs
(
"ReluOut"
).
size
(),
sz
-
1
,
platform
::
errors
::
InvalidArgument
(
"Size of output(ReluOut) of FusionRepeatedFCReluOp should "
"be equal to inputs size minus one %d, but received value is %d"
,
sz
-
1
,
ctx
->
Outputs
(
"ReluOut"
).
size
()));
OP_INOUT_CHECK
(
ctx
->
HasOutput
(
"Out"
),
"Output"
,
"Out"
,
"FusionRepeatedFCRelu"
);
auto
i_dims
=
ctx
->
GetInputDim
(
"X"
);
PADDLE_ENFORCE_EQ
(
i_dims
.
size
(),
2
,
"Input shape size should be 2"
);
PADDLE_ENFORCE_EQ
(
i_dims
.
size
(),
2
,
platform
::
errors
::
InvalidArgument
(
"Input shape size should be 2, but received value is %d."
,
i_dims
.
size
()));
auto
w_dims
=
ctx
->
GetInputsDim
(
"W"
);
auto
b_dims
=
ctx
->
GetInputsDim
(
"Bias"
);
PADDLE_ENFORCE_EQ
(
w_dims
.
size
(),
b_dims
.
size
(),
"Shape size of weight and bias should be equal"
);
PADDLE_ENFORCE_EQ
(
w_dims
.
size
(),
sz
,
"Shape size of weight and bias should be equal"
);
platform
::
errors
::
InvalidArgument
(
"Shape size of weight and bias should be equal, but "
"weight size is %d, bias size is %d."
,
w_dims
.
size
(),
b_dims
.
size
()));
PADDLE_ENFORCE_EQ
(
i_dims
[
1
],
w_dims
[
0
][
0
],
"inpute width should be equal with weight height"
);
platform
::
errors
::
InvalidArgument
(
"input width should be equal to weight height, but "
"input width is %d, weight height is %d."
,
i_dims
[
1
],
w_dims
[
0
][
0
]));
for
(
size_t
i
=
1
;
i
<
sz
;
++
i
)
{
PADDLE_ENFORCE_EQ
(
w_dims
[
i
].
size
(),
2
,
"Every weight shape size should be 2."
);
PADDLE_ENFORCE_EQ
(
framework
::
product
(
b_dims
[
i
]),
w_dims
[
i
][
1
],
"The length of Bias must be equal with w_dims[1]."
);
platform
::
errors
::
InvalidArgument
(
"Every weight shape size should be 2., but received "
"w_dims[%d].size() = %d."
,
i
,
w_dims
[
i
].
size
()));
PADDLE_ENFORCE_EQ
(
framework
::
product
(
b_dims
[
i
]),
w_dims
[
i
][
1
],
platform
::
errors
::
InvalidArgument
(
"The length of Bias must be equal with w_dims[1], but received "
"product(b_dims[%d]) = %d, w_dims[%d][1] = %d."
,
i
,
framework
::
product
(
b_dims
[
i
]),
i
,
w_dims
[
i
][
1
]));
}
ctx
->
SetOutputDim
(
"Out"
,
{
i_dims
[
0
],
w_dims
[
sz
-
1
][
1
]});
ctx
->
ShareLoD
(
"X"
,
/*->*/
"Out"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录