Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
1860ab2e
提交
1860ab2e
authored
6月 02, 2017
作者:
Reyhane Askari
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change of names and fixes for recursive_destroys_finder
上级
5917ead5
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
17 行增加
和
17 行删除
+17
-17
function_module.py
theano/compile/function_module.py
+6
-5
destroyhandler.py
theano/gof/destroyhandler.py
+11
-12
没有找到文件。
theano/compile/function_module.py
浏览文件 @
1860ab2e
...
@@ -132,11 +132,12 @@ class Supervisor:
...
@@ -132,11 +132,12 @@ class Supervisor:
self
.
protected
=
list
(
protected
)
self
.
protected
=
list
(
protected
)
def
validate
(
self
,
fgraph
):
def
validate
(
self
,
fgraph
):
if
config
.
cycle_detection
==
'fast'
and
hasattr
(
fgraph
,
'
fast_destroyers_check
'
):
if
config
.
cycle_detection
==
'fast'
and
hasattr
(
fgraph
,
'
has_destroyers
'
):
if
fgraph
.
fast_destroyers_check
(
self
.
protected
):
if
fgraph
.
has_destroyers
(
self
.
protected
):
raise
gof
.
InconsistencyError
(
"Trying to destroy a protected"
raise
gof
.
InconsistencyError
(
"Trying to destroy a protected"
"Variable."
)
"Variable."
)
else
:
return
True
if
not
hasattr
(
fgraph
,
'destroyers'
):
if
not
hasattr
(
fgraph
,
'destroyers'
):
return
True
return
True
for
r
in
self
.
protected
+
list
(
fgraph
.
outputs
):
for
r
in
self
.
protected
+
list
(
fgraph
.
outputs
):
...
@@ -1090,7 +1091,7 @@ def insert_deepcopy(fgraph, wrapped_inputs, wrapped_outputs):
...
@@ -1090,7 +1091,7 @@ def insert_deepcopy(fgraph, wrapped_inputs, wrapped_outputs):
# We can't use fgraph.inputs as this don't include Constant Value.
# We can't use fgraph.inputs as this don't include Constant Value.
all_graph_inputs
=
gof
.
graph
.
inputs
(
fgraph
.
outputs
)
all_graph_inputs
=
gof
.
graph
.
inputs
(
fgraph
.
outputs
)
has_destroyers
=
hasattr
(
fgraph
,
'get_destroyers_of'
)
has_
get_
destroyers
=
hasattr
(
fgraph
,
'get_destroyers_of'
)
for
i
in
xrange
(
len
(
fgraph
.
outputs
)):
for
i
in
xrange
(
len
(
fgraph
.
outputs
)):
views_of_output_i
=
set
()
views_of_output_i
=
set
()
...
@@ -1121,7 +1122,7 @@ def insert_deepcopy(fgraph, wrapped_inputs, wrapped_outputs):
...
@@ -1121,7 +1122,7 @@ def insert_deepcopy(fgraph, wrapped_inputs, wrapped_outputs):
# being updated
# being updated
if
input_j
in
updated_fgraph_inputs
:
if
input_j
in
updated_fgraph_inputs
:
continue
continue
if
input_j
in
views_of_output_i
and
not
(
has_destroyers
and
fgraph
.
get_destroyers_of
(
input_j
)):
if
input_j
in
views_of_output_i
and
not
(
has_
get_
destroyers
and
fgraph
.
get_destroyers_of
(
input_j
)):
# We don't put deep_copy_op if the input and the
# We don't put deep_copy_op if the input and the
# output have borrow==True
# output have borrow==True
if
input_j
in
fgraph
.
inputs
:
if
input_j
in
fgraph
.
inputs
:
...
...
theano/gof/destroyhandler.py
浏览文件 @
1860ab2e
...
@@ -297,7 +297,7 @@ class DestroyHandler(toolbox.Bookkeeper): # noqa
...
@@ -297,7 +297,7 @@ class DestroyHandler(toolbox.Bookkeeper): # noqa
<unknown>
<unknown>
"""
"""
pickle_rm_attr
=
[
"destroyers"
,
"
fast_destroyers_check
"
]
pickle_rm_attr
=
[
"destroyers"
,
"
has_destroyers
"
]
def
__init__
(
self
,
do_imports_on_attach
=
True
,
algo
=
None
):
def
__init__
(
self
,
do_imports_on_attach
=
True
,
algo
=
None
):
self
.
fgraph
=
None
self
.
fgraph
=
None
...
@@ -395,24 +395,23 @@ class DestroyHandler(toolbox.Bookkeeper): # noqa
...
@@ -395,24 +395,23 @@ class DestroyHandler(toolbox.Bookkeeper): # noqa
fgraph
.
destroyers
=
get_destroyers_of
fgraph
.
destroyers
=
get_destroyers_of
def
recursive_destroys_finder
(
clients_list
):
def
recursive_destroys_finder
(
clients_list
):
for
client
in
clients_list
:
for
(
app
,
idx
)
in
clients_list
:
# client is a tuple (I don't know if its size is always one)
if
app
==
'output'
:
for
item
in
client
:
continue
if
item
.
op
.
destroy_map
:
destroy_maps
=
getattr
(
app
.
op
,
'destroy_map'
,
{})
.
values
()
if
idx
in
[
dmap
for
sublist
in
destroy_maps
for
dmap
in
sublist
]:
return
True
return
True
if
len
(
item
.
outputs
)
==
0
:
for
var
in
getattr
(
app
.
op
,
'view_map'
,
{})
.
keys
():
return
False
if
recursive_destroys_finder
(
app
.
outputs
[
var
]
.
clients
):
for
output
in
item
.
outputs
:
if
recursive_destroys_finder
(
output
.
clients
):
return
True
return
True
return
False
return
False
def
fast_destroyers_check
(
protected_list
):
def
has_destroyers
(
protected_list
):
for
protected_var
in
protected_list
:
for
protected_var
in
protected_list
:
if
recursive_destroys_finder
(
protected_var
.
clients
):
if
recursive_destroys_finder
(
protected_var
.
clients
):
return
True
return
True
fgraph
.
fast_destroyers_check
=
fast_destroyers_check
fgraph
.
has_destroyers
=
has_destroyers
def
refresh_droot_impact
(
self
):
def
refresh_droot_impact
(
self
):
"""
"""
...
@@ -436,7 +435,7 @@ class DestroyHandler(toolbox.Bookkeeper): # noqa
...
@@ -436,7 +435,7 @@ class DestroyHandler(toolbox.Bookkeeper): # noqa
del
self
.
stale_droot
del
self
.
stale_droot
assert
self
.
fgraph
.
destroyer_handler
is
self
assert
self
.
fgraph
.
destroyer_handler
is
self
delattr
(
self
.
fgraph
,
'destroyers'
)
delattr
(
self
.
fgraph
,
'destroyers'
)
delattr
(
self
.
fgraph
,
'
fast_destroyers_check
'
)
delattr
(
self
.
fgraph
,
'
has_destroyers
'
)
delattr
(
self
.
fgraph
,
'destroy_handler'
)
delattr
(
self
.
fgraph
,
'destroy_handler'
)
self
.
fgraph
=
None
self
.
fgraph
=
None
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论