Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
马赛克医院
Paddle
提交
2c4b57e9
P
Paddle
项目概览
马赛克医院
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
2c4b57e9
编写于
4月 09, 2020
作者:
G
GaoWei8
提交者:
GitHub
4月 09, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Op (concat) error message enhancement (#23523)
上级
45880f60
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
18 addition
and
14 deletion
+18
-14
paddle/fluid/operators/concat_op.cc
paddle/fluid/operators/concat_op.cc
+7
-8
paddle/fluid/operators/concat_op.h
paddle/fluid/operators/concat_op.h
+11
-6
未找到文件。
paddle/fluid/operators/concat_op.cc
浏览文件 @
2c4b57e9
...
...
@@ -30,18 +30,17 @@ class ConcatOp : public framework::OperatorWithKernel {
using
framework
::
OperatorWithKernel
::
OperatorWithKernel
;
void
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
override
{
PADDLE_ENFORCE_GE
(
ctx
->
Inputs
(
"X"
).
size
(),
1UL
,
"Inputs(X) of ConcatOp should not be empty."
);
PADDLE_ENFORCE_EQ
(
ctx
->
HasOutput
(
"Out"
),
true
,
"Output(Out) of ConcatOp should not be null."
);
OP_INOUT_CHECK
(
ctx
->
HasInputs
(
"X"
),
"Input"
,
"X"
,
"Concat"
);
OP_INOUT_CHECK
(
ctx
->
HasOutput
(
"Out"
),
"Output"
,
"Out"
,
"Concat"
);
auto
inputs_dims
=
ctx
->
GetInputsDim
(
"X"
);
const
size_t
inputs_num
=
inputs_dims
.
size
();
PADDLE_ENFORCE_GT
(
inputs_num
,
0
,
"ShapeError: Input tensors count should > 0. But "
"recevied inputs' length is 0."
);
PADDLE_ENFORCE_GT
(
inputs_num
,
static_cast
<
size_t
>
(
0
),
platform
::
errors
::
InvalidArgument
(
"The number of input tensors in concat op should > 0. But "
"received inputs' length is 0."
));
if
(
inputs_num
==
1
)
{
VLOG
(
3
)
<<
"Warning: concat op have only one input, may waste memory"
;
}
...
...
paddle/fluid/operators/concat_op.h
浏览文件 @
2c4b57e9
...
...
@@ -49,10 +49,11 @@ static inline framework::DDim ComputeAndCheckShape(
// check all shape in run time
PADDLE_ENFORCE_EQ
(
inputs_dims
[
0
][
j
],
inputs_dims
[
i
][
j
],
"ShapeError: Dimension %d in inputs' shapes must be equal. "
"But recevied input[0]'s shape = "
"[%s], input[%d]'s shape = [%s]."
,
j
,
inputs_dims
[
0
],
i
,
inputs_dims
[
i
]);
platform
::
errors
::
InvalidArgument
(
"The shape of input[%d] must be equal to input[0]. "
"But received input[0]'s shape = "
"[%s], input[%d]'s shape = [%s]."
,
i
,
inputs_dims
[
0
],
i
,
inputs_dims
[
i
]));
}
}
}
...
...
@@ -78,7 +79,9 @@ class ConcatKernel : public framework::OpKernel<T> {
void
Compute
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
auto
ins
=
ctx
.
MultiInput
<
framework
::
LoDTensor
>
(
"X"
);
framework
::
LoDTensor
*
out
=
ctx
.
Output
<
framework
::
LoDTensor
>
(
"Out"
);
PADDLE_ENFORCE_EQ
(
ins
[
0
]
!=
nullptr
,
true
,
"The input should not be null."
);
PADDLE_ENFORCE_NOT_NULL
(
ins
[
0
],
platform
::
errors
::
NotFound
(
" The first input of concat should not be null."
));
auto
axis
=
ctx
.
Attr
<
int
>
(
"axis"
);
bool
need_resize_out_dims
=
false
;
if
(
ctx
.
HasInput
(
"AxisTensor"
))
{
...
...
@@ -178,7 +181,9 @@ class ConcatGradKernel : public framework::OpKernel<T> {
}
}
}
PADDLE_ENFORCE_EQ
(
ins
[
0
]
!=
nullptr
,
true
,
"The input should not be null."
);
PADDLE_ENFORCE_NOT_NULL
(
ins
[
0
],
platform
::
errors
::
NotFound
(
"The first input of concat should not be null."
));
auto
axis
=
ctx
.
Attr
<
int
>
(
"axis"
);
if
(
ctx
.
HasInput
(
"AxisTensor"
))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录