Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2301_76559479
Paddle
提交
55d0c8fd
P
Paddle
项目概览
2301_76559479
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
0
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,发现更多精彩内容 >>
未验证
提交
55d0c8fd
编写于
4月 08, 2020
作者:
Y
Yiqun Liu
提交者:
GitHub
4月 08, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Enhance the error message of feed_op. (#23526)
上级
71b5f1d2
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
36 addition
and
15 deletion
+36
-15
paddle/fluid/operators/controlflow/feed_op.cc
paddle/fluid/operators/controlflow/feed_op.cc
+36
-15
未找到文件。
paddle/fluid/operators/controlflow/feed_op.cc
浏览文件 @
55d0c8fd
...
...
@@ -28,35 +28,52 @@ class FeedOp : public framework::OperatorBase {
private:
void
RunImpl
(
const
framework
::
Scope
&
scope
,
const
platform
::
Place
&
place
)
const
override
{
// get device context from pool
auto
*
dev_ctx
=
platform
::
DeviceContextPool
::
Instance
().
Get
(
place
);
OP_INOUT_CHECK
(
HasInputs
(
"X"
),
"Input"
,
"X"
,
"Feed"
);
OP_INOUT_CHECK
(
HasOutputs
(
"Out"
),
"Output"
,
"Out"
,
"Feed"
);
auto
feed_var_name
=
Input
(
"X"
);
auto
*
feed_var
=
scope
.
FindVar
(
feed_var_name
);
PADDLE_ENFORCE
(
feed_var
!=
nullptr
,
"Cannot find feed_var in scope, feed_var_name is %s"
,
feed_var_name
);
PADDLE_ENFORCE_NOT_NULL
(
feed_var
,
platform
::
errors
::
NotFound
(
"Input varibale(%s) cannot be found in scope for operator 'Feed'."
,
feed_var_name
));
auto
out_name
=
this
->
Output
(
"Out"
);
auto
*
out_var
=
scope
.
FindVar
(
out_name
);
PADDLE_ENFORCE
(
out_var
!=
nullptr
,
"Cannot find out_var in scope, out_var_name is %s"
,
out_name
);
PADDLE_ENFORCE_NOT_NULL
(
out_var
,
platform
::
errors
::
NotFound
(
"Output variable(%s) cannot be found in scope for operator 'Feed'"
,
out_name
));
auto
col
=
Attr
<
int
>
(
"col"
);
PADDLE_ENFORCE_GE
(
col
,
0
,
platform
::
errors
::
InvalidArgument
(
"Expected the column index (the attribute 'col' of "
"operator 'Feed') of current feeding variable to be "
"no less than 0. But received column index = %d."
,
col
));
VLOG
(
3
)
<<
"Feed
Var "
<<
feed_var_name
<<
"'s "
<<
col
<<
" column to var "
<<
out_name
;
VLOG
(
3
)
<<
"Feed
variable "
<<
feed_var_name
<<
"'s "
<<
col
<<
" column to variable "
<<
out_name
;
auto
&
feed_list
=
feed_var
->
Get
<
framework
::
FeedFetchList
>
();
PADDLE_ENFORCE_LT
(
static_cast
<
size_t
>
(
col
),
feed_list
.
size
());
PADDLE_ENFORCE_LT
(
static_cast
<
size_t
>
(
col
),
feed_list
.
size
(),
platform
::
errors
::
InvalidArgument
(
"The column index of current feeding variable is expected to be "
"less than the length of feeding list. But received column index = "
"%d, the length of feeding list = %d"
,
col
,
feed_list
.
size
()));
auto
&
feed_item
=
feed_list
.
at
(
static_cast
<
size_t
>
(
col
));
auto
*
out_item
=
out_var
->
GetMutable
<
framework
::
FeedFetchType
>
();
if
(
platform
::
is_same_place
(
feed_item
.
place
(),
place
))
{
out_item
->
ShareDataWith
(
feed_item
);
}
else
{
auto
*
dev_ctx
=
platform
::
DeviceContextPool
::
Instance
().
Get
(
place
);
framework
::
TensorCopy
(
feed_item
,
place
,
*
dev_ctx
,
out_item
);
}
out_item
->
set_lod
(
feed_item
.
lod
());
...
...
@@ -66,9 +83,13 @@ class FeedOp : public framework::OperatorBase {
class
FeedOpInfoMaker
:
public
framework
::
OpProtoAndCheckerMaker
{
public:
void
Make
()
override
{
AddInput
(
"X"
,
"The input of feed op"
);
AddOutput
(
"Out"
,
"The output of feed op"
);
AddAttr
<
int
>
(
"col"
,
"(int) The column of feed"
);
AddInput
(
"X"
,
"(vector<LoDTensor>) A feeding list of LoDTensor, which may have "
"different dimension and data type."
);
AddOutput
(
"Out"
,
"(LoDTensor) The LoDTensor which is a copy of the col-th feeding "
"object."
);
AddAttr
<
int
>
(
"col"
,
"(int) The column index of current feeding object."
);
AddComment
(
R"DOC(
Feed Operator.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录