Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
4489f0d3
P
Paddle
项目概览
BaiXuePrincess
/
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看板
未验证
提交
4489f0d3
编写于
4月 09, 2020
作者:
Y
Yiqun Liu
提交者:
GitHub
4月 09, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Op(fetch) error message enhancement. (#23542)
上级
2cf27260
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
32 addition
and
15 deletion
+32
-15
paddle/fluid/operators/controlflow/fetch_op.cc
paddle/fluid/operators/controlflow/fetch_op.cc
+32
-15
未找到文件。
paddle/fluid/operators/controlflow/fetch_op.cc
浏览文件 @
4489f0d3
...
...
@@ -31,24 +31,39 @@ class FetchOp : public framework::OperatorBase {
private:
void
RunImpl
(
const
framework
::
Scope
&
scope
,
const
platform
::
Place
&
place
)
const
override
{
OP_INOUT_CHECK
(
HasInputs
(
"X"
),
"Input"
,
"X"
,
"Fetch"
);
OP_INOUT_CHECK
(
HasOutputs
(
"Out"
),
"Output"
,
"Out"
,
"Fetch"
);
auto
fetch_var_name
=
Input
(
"X"
);
auto
*
fetch_var
=
scope
.
FindVar
(
fetch_var_name
);
PADDLE_ENFORCE
(
fetch_var
!=
nullptr
,
"Cannot find fetch variable in scope, fetch_var_name is %s"
,
fetch_var_name
);
PADDLE_ENFORCE_NOT_NULL
(
fetch_var
,
platform
::
errors
::
NotFound
(
"Input variable(%s) cannot be found in scope for operator 'Fetch'."
,
fetch_var_name
));
auto
out_name
=
this
->
Output
(
"Out"
);
auto
out_name
=
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
);
auto
col
=
static_cast
<
size_t
>
(
Attr
<
int
>
(
"col"
));
PADDLE_ENFORCE_NOT_NULL
(
out_var
,
platform
::
errors
::
NotFound
(
"Output variable(%s) cannot be found "
"in scope for operator 'Fetch'."
,
out_name
));
int
col
=
Attr
<
int
>
(
"col"
);
PADDLE_ENFORCE_GE
(
col
,
0
,
platform
::
errors
::
InvalidArgument
(
"Expected the column index (the attribute 'col' of "
"operator 'Fetch') of current fetching variable to be "
"no less than 0. But received column index = %d."
,
col
));
VLOG
(
3
)
<<
"Fetch variable "
<<
fetch_var_name
<<
" to variable "
<<
out_name
<<
"'s "
<<
col
<<
" column."
;
auto
*
fetch_list
=
out_var
->
GetMutable
<
framework
::
FeedFetchList
>
();
auto
&
src_item
=
fetch_var
->
Get
<
framework
::
FeedFetchType
>
();
if
(
col
>=
fetch_list
->
size
())
{
if
(
static_cast
<
size_t
>
(
col
)
>=
fetch_list
->
size
())
{
fetch_list
->
resize
(
col
+
1
);
}
auto
&
dst_item
=
fetch_list
->
at
(
col
);
...
...
@@ -81,17 +96,19 @@ class FetchOp : public framework::OperatorBase {
dst_item
.
Resize
({
0
});
}
dst_item
.
set_lod
(
src_item
.
lod
());
VLOG
(
3
)
<<
"Fetch variable "
<<
fetch_var_name
<<
" to "
<<
out_name
;
}
};
class
FetchOpInfoMaker
:
public
framework
::
OpProtoAndCheckerMaker
{
public:
void
Make
()
override
{
AddInput
(
"X"
,
"The input of fetch op"
);
AddOutput
(
"Out"
,
"The output of fetch op"
);
AddAttr
<
int
>
(
"col"
,
"(int) The column of fetch"
);
AddInput
(
"X"
,
"(LoDTensor) The resulted LoDTensor which is expected to return "
"to users."
);
AddOutput
(
"Out"
,
"(vector<LoDTensor>) A fetching list of LoDTensor which may have "
"different dimension, shape and data type."
);
AddAttr
<
int
>
(
"col"
,
"(int) The column index of fetching object."
);
AddComment
(
R"DOC(
Fetch Operator.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录