Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
ed9cdb56
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
Star
20931
Fork
5422
代码
文件
提交
分支
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看板
未验证
提交
ed9cdb56
编写于
12月 10, 2018
作者:
X
Xin Pan
提交者:
GitHub
12月 10, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #14823 from panyx0718/fix
fix control_flow ops in outs
上级
4a716a70
f5434507
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
30 addition
and
13 deletion
+30
-13
python/paddle/fluid/framework.py
python/paddle/fluid/framework.py
+22
-7
python/paddle/fluid/layers/control_flow.py
python/paddle/fluid/layers/control_flow.py
+8
-6
未找到文件。
python/paddle/fluid/framework.py
浏览文件 @
ed9cdb56
...
...
@@ -1084,19 +1084,15 @@ class Block(object):
raise
ValueError
(
"var %s not in this block"
%
name
)
return
v
def
_var_recursive
(
self
,
name
):
def
_
find_
var_recursive
(
self
,
name
):
"""
Get a Variable by name from this block recursively.
Args:
name(str): the Variable's name.
Raises:
ValueError: this block and this parent block doesn't
have a Variable with the giving name.
Returns:
Variable: the Variable with the giving name.
Variable: the Variable with the giving name.
Or None if not found.
"""
frontier
=
list
()
visited
=
set
()
...
...
@@ -1122,8 +1118,27 @@ class Block(object):
frontier
.
append
(
prog
.
block
(
cur
.
forward_block_idx
))
visited
.
add
(
id
(
cur
))
return
None
raise
ValueError
(
"Var {0} is not found recursively"
.
format
(
name
))
def
_var_recursive
(
self
,
name
):
"""
Get a Variable by name from this block recursively.
Args:
name(str): the Variable's name.
Raises:
ValueError: this block and this parent block doesn't
have a Variable with the giving name.
Returns:
Variable: the Variable with the giving name.
"""
var
=
self
.
_find_var_recursive
(
name
)
if
var
:
return
var
else
:
raise
ValueError
(
"Var {0} is not found recursively"
.
format
(
name
))
def
all_parameters
(
self
):
return
list
(
self
.
iter_parameters
())
...
...
python/paddle/fluid/layers/control_flow.py
浏览文件 @
ed9cdb56
...
...
@@ -717,8 +717,9 @@ class While(object):
out_vars
=
[]
for
inner_out_name
in
inner_outputs
:
if
inner_out_name
in
parent_block
.
vars
:
out_vars
.
append
(
parent_block
.
var
(
inner_out_name
))
inner_var
=
parent_block
.
_find_var_recursive
(
inner_out_name
)
if
inner_var
:
out_vars
.
append
(
inner_var
)
step_scope
=
parent_block
.
create_var
(
type
=
core
.
VarDesc
.
VarType
.
STEP_SCOPES
)
...
...
@@ -1264,10 +1265,11 @@ class ConditionalBlock(object):
if
each_name
not
in
input_set
]
out_list
=
[
parent_block
.
var
(
var_name
)
for
var_name
in
parent_block
.
vars
if
var_name
in
intermediate
]
out_list
=
[]
for
inner_out_name
in
intermediate
:
inner_var
=
parent_block
.
_find_var_recursive
(
inner_out_name
)
if
inner_var
:
out_list
.
append
(
inner_var
)
step_scope
=
parent_block
.
create_var
(
type
=
core
.
VarDesc
.
VarType
.
STEP_SCOPES
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录