Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
de3e299d
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看板
未验证
提交
de3e299d
编写于
4月 14, 2020
作者:
Y
yiicy
提交者:
GitHub
4月 14, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fusion_seqexpand_concat_fc error message enhancement, test=develop (#23558)
上级
a1e73879
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
73 addition
and
28 deletion
+73
-28
paddle/fluid/operators/fused/fusion_seqexpand_concat_fc_op.cc
...le/fluid/operators/fused/fusion_seqexpand_concat_fc_op.cc
+73
-28
未找到文件。
paddle/fluid/operators/fused/fusion_seqexpand_concat_fc_op.cc
浏览文件 @
de3e299d
...
@@ -24,38 +24,59 @@ namespace operators {
...
@@ -24,38 +24,59 @@ namespace operators {
void
FusionSeqExpandConcatFCOp
::
InferShape
(
void
FusionSeqExpandConcatFCOp
::
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
{
framework
::
InferShapeContext
*
ctx
)
const
{
PADDLE_ENFORCE_GT
(
PADDLE_ENFORCE_GT
(
ctx
->
Inputs
(
"X"
).
size
(),
1UL
,
ctx
->
Inputs
(
"X"
).
size
(),
1UL
,
platform
::
errors
::
InvalidArgument
(
"Inputs(X) of FusionSeqExpandConcatFCOp should larger than 1."
);
"Inputs(X) of FusionSeqExpandConcatFCOp should larger "
PADDLE_ENFORCE
(
"than 1, but received value is: %d."
,
ctx
->
HasInput
(
"FCWeight"
),
ctx
->
Inputs
(
"X"
).
size
()));
"Input(FCWeight) of FusionSeqExpandConcatFCOp should not be null."
);
OP_INOUT_CHECK
(
ctx
->
HasInput
(
"FCWeight"
),
"Input"
,
"FCWeight"
,
PADDLE_ENFORCE
(
"fusion_seqexpand_concat_fc"
);
ctx
->
HasOutput
(
"Out"
),
OP_INOUT_CHECK
(
ctx
->
HasOutput
(
"Out"
),
"Output"
,
"Out"
,
"Output(Out) of FusionSeqExpandConcatFCOp should not be null."
);
"fusion_seqexpand_concat_fc"
);
PADDLE_ENFORCE
(
OP_INOUT_CHECK
(
ctx
->
HasOutput
(
"FCOut"
),
"Output"
,
"FCOut"
,
ctx
->
HasOutput
(
"FCOut"
),
"fusion_seqexpand_concat_fc"
);
"Output(FCOut) of FusionSeqExpandConcatFCOp should not be null."
);
auto
ins_dims
=
ctx
->
GetInputsDim
(
"X"
);
auto
ins_dims
=
ctx
->
GetInputsDim
(
"X"
);
auto
w_dims
=
ctx
->
GetInputDim
(
"FCWeight"
);
// (M0+M1+M2+..) x D
auto
w_dims
=
ctx
->
GetInputDim
(
"FCWeight"
);
// (M0+M1+M2+..) x D
PADDLE_ENFORCE_EQ
(
w_dims
.
size
(),
2
,
"Input(FCWeight)'s rank must be 2."
);
PADDLE_ENFORCE_EQ
(
w_dims
.
size
(),
2
,
platform
::
errors
::
InvalidArgument
(
"Input(FCWeight)'s rank must be 2, but received value is: %d."
,
w_dims
.
size
()));
const
int
D
=
w_dims
[
1
];
const
int
D
=
w_dims
[
1
];
int
sum
=
ins_dims
[
0
][
1
];
int
sum
=
ins_dims
[
0
][
1
];
for
(
size_t
i
=
1
;
i
<
ins_dims
.
size
();
++
i
)
{
for
(
size_t
i
=
1
;
i
<
ins_dims
.
size
();
++
i
)
{
sum
+=
ins_dims
[
i
][
1
];
sum
+=
ins_dims
[
i
][
1
];
}
}
PADDLE_ENFORCE_EQ
(
sum
,
w_dims
[
0
],
PADDLE_ENFORCE_EQ
(
sum
,
w_dims
[
0
],
platform
::
errors
::
InvalidArgument
(
"FC height should be sum of all inputs width."
);
"FC height should be sum of all inputs "
"width, but received FC height is: %d, "
"sum of all inputs width is: %d."
,
w_dims
[
0
],
sum
));
if
(
ctx
->
HasInput
(
"FCBias"
))
{
if
(
ctx
->
HasInput
(
"FCBias"
))
{
auto
b_dims
=
ctx
->
GetInputDim
(
"FCBias"
);
auto
b_dims
=
ctx
->
GetInputDim
(
"FCBias"
);
PADDLE_ENFORCE
(
b_dims
.
size
()
==
1
||
b_dims
.
size
()
==
2
,
PADDLE_ENFORCE_EQ
(
"b_dims should be 1 or 2, get %d"
,
b_dims
.
size
());
b_dims
.
size
()
==
1
||
b_dims
.
size
()
==
2
,
true
,
platform
::
errors
::
InvalidArgument
(
"FCBias dim should be 1 or 2, but received value is: %d."
,
b_dims
.
size
()));
if
(
b_dims
.
size
()
==
1
)
{
if
(
b_dims
.
size
()
==
1
)
{
PADDLE_ENFORCE_EQ
(
b_dims
[
0
],
D
,
"FCBias shapes must be %d."
,
D
);
PADDLE_ENFORCE_EQ
(
b_dims
[
0
],
D
,
platform
::
errors
::
InvalidArgument
(
"FCBias shapes must be %d when FCBias dim = 1, but "
"received value is: %d."
,
D
,
b_dims
[
0
]));
}
else
{
}
else
{
PADDLE_ENFORCE_EQ
(
b_dims
[
0
],
1
,
"FCBias shapes must be 1x%d."
,
D
);
PADDLE_ENFORCE_EQ
(
b_dims
[
0
],
1
,
PADDLE_ENFORCE_EQ
(
b_dims
[
1
],
D
,
"FCBias shapes must be 1x%d."
,
D
);
platform
::
errors
::
InvalidArgument
(
"FCBias shapes must be 1x%d, when FCBias dim = 2, "
"but received dim[0] is: %d."
,
D
,
b_dims
[
0
]));
PADDLE_ENFORCE_EQ
(
b_dims
[
1
],
D
,
platform
::
errors
::
InvalidArgument
(
"FCBias shapes must be 1x%d, when FCBias dim = 2, "
"but received dim[1] is: %d."
,
D
,
b_dims
[
1
]));
}
}
}
}
...
@@ -133,18 +154,42 @@ class FusionSeqExpandConcatFCOpKernel : public framework::OpKernel<T> {
...
@@ -133,18 +154,42 @@ class FusionSeqExpandConcatFCOpKernel : public framework::OpKernel<T> {
// some check and fcout should be reshape here
// some check and fcout should be reshape here
// since infershape can not get lod info
// since infershape can not get lod info
PADDLE_ENFORCE_EQ
(
ref_lod
.
size
(),
1UL
,
"Only support input lod size is 1."
);
PADDLE_ENFORCE_EQ
(
PADDLE_ENFORCE_EQ
(
in1_lod
.
size
(),
1UL
,
"Only support input lod size is 1."
);
ref_lod
.
size
(),
1UL
,
platform
::
errors
::
InvalidArgument
(
"Only support input lod size is 1, but received value is: %d."
,
ref_lod
.
size
()));
PADDLE_ENFORCE_EQ
(
in1_lod
.
size
(),
1UL
,
platform
::
errors
::
InvalidArgument
(
"Only support input lod size is 1, but received value is: %d."
,
in1_lod
.
size
()));
PADDLE_ENFORCE_EQ
(
static_cast
<
int
>
(
in1_lod
[
0
].
size
()
-
1
),
N
,
PADDLE_ENFORCE_EQ
(
static_cast
<
int
>
(
in1_lod
[
0
].
size
()
-
1
),
N
,
"Batch size of all inputs should be equal."
);
platform
::
errors
::
InvalidArgument
(
PADDLE_ENFORCE_EQ
(
static_cast
<
int
>
(
in1_lod
[
0
][
N
]),
N
,
"Batch size of all inputs should be equal to %d, but "
"Seq_length of other inputs should be 1."
);
"received value is: %d."
,
PADDLE_ENFORCE_EQ
(
in1_dims
[
0
],
N
,
"input height should be batch size."
);
N
,
static_cast
<
int
>
(
in1_lod
[
0
].
size
()
-
1
)));
PADDLE_ENFORCE_EQ
(
static_cast
<
int
>
(
in1_lod
[
0
][
N
]),
N
,
platform
::
errors
::
InvalidArgument
(
"Seq_length of other inputs should "
"be %d, but received value is: %d."
,
N
,
static_cast
<
int
>
(
in1_lod
[
0
][
N
])));
PADDLE_ENFORCE_EQ
(
in1_dims
[
0
],
N
,
platform
::
errors
::
InvalidArgument
(
"input height should be batch size: %d, but received value is %d."
,
N
,
in1_dims
[
0
]));
for
(
size_t
i
=
2
;
i
<
ins
.
size
();
++
i
)
{
for
(
size_t
i
=
2
;
i
<
ins
.
size
();
++
i
)
{
PADDLE_ENFORCE_EQ
(
ins
[
i
]
->
dims
()[
0
],
N
,
PADDLE_ENFORCE_EQ
(
ins
[
i
]
->
dims
()[
0
],
N
,
"All other inputs height should be equal"
);
platform
::
errors
::
InvalidArgument
(
"All other inputs height should be equal to %d, "
"but received value is: %d."
,
N
,
ins
[
i
]
->
dims
()[
0
]));
PADDLE_ENFORCE_EQ
(
ins
[
i
]
->
lod
(),
in1_lod
,
PADDLE_ENFORCE_EQ
(
ins
[
i
]
->
lod
(),
in1_lod
,
"All other inputs should have same lod"
);
platform
::
errors
::
InvalidArgument
(
"All other inputs should have same lod: %d, but "
"received value is: %d."
,
in1_lod
,
ins
[
i
]
->
lod
()));
}
}
fc_out
->
Resize
({
N
,
D
});
fc_out
->
Resize
({
N
,
D
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录