Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
1ac9db43
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看板
未验证
提交
1ac9db43
编写于
4月 10, 2020
作者:
W
Wilber
提交者:
GitHub
4月 10, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
error message enhancement for fusion_seqpool_concat_op. test=develop (#23563)
error message enhancement for fusion_seqpool_concat_op
上级
286c2e0e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
33 addition
and
12 deletion
+33
-12
paddle/fluid/operators/fused/fusion_seqpool_concat_op.cc
paddle/fluid/operators/fused/fusion_seqpool_concat_op.cc
+33
-12
未找到文件。
paddle/fluid/operators/fused/fusion_seqpool_concat_op.cc
浏览文件 @
1ac9db43
...
...
@@ -23,16 +23,23 @@ namespace operators {
void
FusionSeqPoolConcatOp
::
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
{
PADDLE_ENFORCE_GE
(
ctx
->
Inputs
(
"X"
).
size
(),
1UL
,
"Inputs(X) of FusionSeqPoolConcatOp should not be empty."
);
PADDLE_ENFORCE
(
ctx
->
HasOutput
(
"Out"
),
"Output(Out) of FusionSeqPoolConcatOp should not be null."
);
platform
::
errors
::
InvalidArgument
(
"Inputs(X) of FusionSeqPoolConcatOp should be greated "
"than 1, but received value is %d."
,
ctx
->
Inputs
(
"X"
).
size
()));
OP_INOUT_CHECK
(
ctx
->
HasOutput
(
"Out"
),
"Output"
,
"Out"
,
"FusionSeqPoolConcat"
);
int
axis
=
ctx
->
Attrs
().
Get
<
int
>
(
"axis"
);
PADDLE_ENFORCE_EQ
(
axis
,
1
,
"FusionSeqPoolConcatOp only supports concat axis=1 yet."
);
PADDLE_ENFORCE_EQ
(
axis
,
1
,
platform
::
errors
::
InvalidArgument
(
"FusionSeqPoolConcatOp only supports concat "
"axis=1 yet, but received axis value is %d"
,
axis
));
auto
ins_dims
=
ctx
->
GetInputsDim
(
"X"
);
const
size_t
n
=
ins_dims
.
size
();
PADDLE_ENFORCE_GT
(
n
,
0UL
,
"Input tensors count should > 0."
);
PADDLE_ENFORCE_GT
(
n
,
0UL
,
platform
::
errors
::
InvalidArgument
(
"Input tensors count should be greater than 0, "
"but received value is %d."
,
n
));
if
(
n
==
1
)
{
LOG
(
WARNING
)
<<
"Only have one input, may waste memory"
;
}
...
...
@@ -40,7 +47,10 @@ void FusionSeqPoolConcatOp::InferShape(
// The output height should be confirmed in Compute,
// since input lod is not accessible here.
PADDLE_ENFORCE_EQ
(
ins_dims
[
0
].
size
(),
2
,
"The dims size of first input should be 2."
);
platform
::
errors
::
InvalidArgument
(
"The dims size of first input should be equal to 2, "
"but received value is %d."
,
ins_dims
[
0
].
size
()));
ctx
->
SetOutputDim
(
"Out"
,
{
-
1
,
ins_dims
[
0
][
axis
]
*
static_cast
<
int
>
(
n
)});
if
(
!
ctx
->
IsRuntime
())
{
...
...
@@ -96,7 +106,10 @@ class FusionSeqPoolConcatKernel : public framework::OpKernel<T> {
int
w
=
ins
[
0
]
->
numel
()
/
x0_dims
[
0
];
PADDLE_ENFORCE_EQ
(
y_dims
[
1
]
%
w
,
0
,
"The output of dims[1] should be dividable of w"
);
platform
::
errors
::
InvalidArgument
(
"The output of dims[1] should be dividable of w, but "
"dims[1] is %d, w is %d."
,
y_dims
[
1
],
w
));
jit
::
seq_pool_attr_t
attr
(
w
,
jit
::
SeqPoolType
::
kSum
);
if
(
pooltype
==
"AVERAGE"
)
{
attr
.
type
=
jit
::
SeqPoolType
::
kAvg
;
...
...
@@ -113,10 +126,18 @@ class FusionSeqPoolConcatKernel : public framework::OpKernel<T> {
auto
x_lod
=
ins
[
i
]
->
lod
()[
0
];
const
T
*
src
=
ins
[
i
]
->
data
<
T
>
();
T
*
dst
=
y_data
+
i
*
w
;
PADDLE_ENFORCE_EQ
(
static_cast
<
int
>
(
ins
[
i
]
->
numel
()
/
x_dims
[
0
]),
w
,
"Width of all inputs should be equal."
);
PADDLE_ENFORCE_EQ
(
x_lod
.
size
(),
bs
+
1
,
"Batchsize of all inputs should be equal."
);
PADDLE_ENFORCE_EQ
(
static_cast
<
int
>
(
ins
[
i
]
->
numel
()
/
x_dims
[
0
]),
w
,
platform
::
errors
::
InvalidArgument
(
"Width of all inputs should be equal, but the width of the %d-th "
"input %d is not equal to the previous %d"
,
i
,
static_cast
<
int
>
(
ins
[
i
]
->
numel
()
/
x_dims
[
0
]),
w
));
PADDLE_ENFORCE_EQ
(
x_lod
.
size
(),
bs
+
1
,
platform
::
errors
::
InvalidArgument
(
"Batchsize of all inputs should be equal, but the value of the "
"%d-th %d is not equal to the previous %d."
,
i
,
x_lod
.
size
(),
bs
+
1
));
for
(
size_t
j
=
0
;
j
<
bs
;
++
j
)
{
attr
.
h
=
static_cast
<
int
>
(
x_lod
[
j
+
1
]
-
x_lod
[
j
]);
seqpool
(
src
,
dst
,
&
attr
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录