Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
1b10a784
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
1b10a784
编写于
2月 27, 2019
作者:
Y
Yiqun Liu
提交者:
ceci3
3月 04, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Optimize while_op when is_test is true. (#15811)
test=develop
上级
91838c32
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
30 addition
and
5 deletion
+30
-5
paddle/fluid/framework/lod_rank_table.cc
paddle/fluid/framework/lod_rank_table.cc
+4
-0
paddle/fluid/operators/controlflow/while_op.cc
paddle/fluid/operators/controlflow/while_op.cc
+26
-5
未找到文件。
paddle/fluid/framework/lod_rank_table.cc
浏览文件 @
1b10a784
...
@@ -19,6 +19,10 @@ namespace framework {
...
@@ -19,6 +19,10 @@ namespace framework {
void
LoDRankTable
::
Reset
(
const
LoD
&
lod
,
size_t
level
)
{
void
LoDRankTable
::
Reset
(
const
LoD
&
lod
,
size_t
level
)
{
this
->
coarse_lod_
.
clear
();
this
->
coarse_lod_
.
clear
();
this
->
items_
.
clear
();
this
->
items_
.
clear
();
if
(
lod
.
size
()
==
0
)
{
// Reset to a empty rank table.
return
;
}
PADDLE_ENFORCE
(
level
<
lod
.
size
(),
PADDLE_ENFORCE
(
level
<
lod
.
size
(),
"Cannot rank lod since the level %d is less than lod size %d"
,
"Cannot rank lod since the level %d is less than lod size %d"
,
level
,
lod
.
size
());
level
,
lod
.
size
());
...
...
paddle/fluid/operators/controlflow/while_op.cc
浏览文件 @
1b10a784
...
@@ -58,6 +58,7 @@ class WhileOp : public framework::OperatorBase {
...
@@ -58,6 +58,7 @@ class WhileOp : public framework::OperatorBase {
void
RunImpl
(
const
framework
::
Scope
&
scope
,
void
RunImpl
(
const
framework
::
Scope
&
scope
,
const
platform
::
Place
&
dev_place
)
const
override
{
const
platform
::
Place
&
dev_place
)
const
override
{
PADDLE_ENFORCE_NOT_NULL
(
scope
.
FindVar
(
Input
(
kCondition
)));
PADDLE_ENFORCE_NOT_NULL
(
scope
.
FindVar
(
Input
(
kCondition
)));
auto
&
cond
=
scope
.
FindVar
(
Input
(
kCondition
))
->
Get
<
LoDTensor
>
();
auto
&
cond
=
scope
.
FindVar
(
Input
(
kCondition
))
->
Get
<
LoDTensor
>
();
PADDLE_ENFORCE_EQ
(
cond
.
dims
(),
paddle
::
framework
::
make_ddim
({
1
}));
PADDLE_ENFORCE_EQ
(
cond
.
dims
(),
paddle
::
framework
::
make_ddim
({
1
}));
...
@@ -77,13 +78,33 @@ class WhileOp : public framework::OperatorBase {
...
@@ -77,13 +78,33 @@ class WhileOp : public framework::OperatorBase {
VLOG
(
2
)
<<
GetSkipEagerDeletionVarsDebugString
(
skip_vars
);
VLOG
(
2
)
<<
GetSkipEagerDeletionVarsDebugString
(
skip_vars
);
auto
ctx
=
executor
.
Prepare
(
*
program
,
block
->
ID
(),
skip_vars
);
auto
ctx
=
executor
.
Prepare
(
*
program
,
block
->
ID
(),
skip_vars
);
if
(
!
is_test
)
{
while
(
cond
.
data
<
bool
>
()[
0
])
{
while
(
cond
.
data
<
bool
>
()[
0
])
{
auto
&
current_scope
=
scope
.
NewScope
();
auto
&
current_scope
=
scope
.
NewScope
();
step_scopes
->
push_back
(
&
current_scope
);
step_scopes
->
push_back
(
&
current_scope
);
executor
.
RunPreparedContext
(
ctx
.
get
(),
&
current_scope
,
false
,
true
,
true
);
executor
.
RunPreparedContext
(
ctx
.
get
(),
&
current_scope
,
false
,
true
,
if
(
is_test
)
{
true
);
scope
.
DeleteScope
(
&
current_scope
);
}
}
else
{
auto
&
current_scope
=
scope
.
NewScope
();
executor
.
CreateVariables
(
*
program
,
&
current_scope
,
block
->
ID
());
while
(
cond
.
data
<
bool
>
()[
0
])
{
for
(
auto
&
name
:
current_scope
.
LocalVarNames
())
{
auto
*
var
=
current_scope
.
Var
(
name
);
framework
::
LoD
empty_lod
;
if
(
var
->
IsType
<
framework
::
LoDTensor
>
())
{
// Clear all lod information for all lod_tensors.
auto
*
t
=
var
->
GetMutable
<
framework
::
LoDTensor
>
();
t
->
set_lod
(
empty_lod
);
}
else
if
(
var
->
IsType
<
framework
::
LoDRankTable
>
())
{
auto
*
t
=
var
->
GetMutable
<
framework
::
LoDRankTable
>
();
t
->
Reset
(
empty_lod
,
0
);
}
}
}
executor
.
RunPreparedContext
(
ctx
.
get
(),
&
current_scope
,
false
,
false
,
false
);
}
scope
.
DeleteScope
(
&
current_scope
);
}
}
}
}
};
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录