Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
4812ace3
提交
4812ace3
authored
3月 31, 2017
作者:
Reyhane Askari
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added flag disbale_cycle_detection
上级
5f417aaa
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
31 行增加
和
15 行删除
+31
-15
configdefaults.py
theano/configdefaults.py
+6
-0
destroyhandler.py
theano/gof/destroyhandler.py
+25
-15
没有找到文件。
theano/configdefaults.py
浏览文件 @
4812ace3
...
...
@@ -1478,6 +1478,12 @@ AddConfigVar('compile.wait',
IntParam
(
5
,
lambda
i
:
i
>
0
,
allow_override
=
False
),
in_c_key
=
False
)
AddConfigVar
(
'disbale_cycle_detection'
,
"""If true it disables the cycle detection in graph.
"""
,
BoolParam
(
False
),
in_c_key
=
False
)
def
_timeout_default
():
return
theano
.
config
.
compile
.
wait
*
24
...
...
theano/gof/destroyhandler.py
浏览文件 @
4812ace3
...
...
@@ -10,6 +10,7 @@ from collections import deque, OrderedDict
from
six
import
iteritems
import
theano
from
theano
import
config
from
.
import
toolbox
from
.
import
graph
from
theano.misc.ordered_set
import
OrderedSet
...
...
@@ -738,6 +739,7 @@ class DestroyHandler(toolbox.Bookkeeper): # noqa
# clients: how many times does an apply use a given variable
self
.
clients
=
OrderedDict
()
# variable -> apply -> ninputs
self
.
stale_droot
=
True
self
.
fail_validate
=
False
self
.
debug_all_apps
=
OrderedSet
()
if
self
.
do_imports_on_attach
:
...
...
@@ -788,24 +790,27 @@ class DestroyHandler(toolbox.Bookkeeper): # noqa
- Allow sequence of view.
- But don't allow to destroy view
"""
return
dm
=
getattr
(
app
.
op
,
'destroy_map'
,
None
)
if
not
dm
:
return
inputs
=
sum
(
dm
.
values
())
# list of app's destroyed inputs
# inputs = sum(dm.values()) # list of app's destroyed inputs
inputs
=
dm
.
values
()[
0
]
for
inp_idx
in
inputs
:
inp
=
app
.
inputs
[
inp_idx
]
if
inp
.
owner
:
if
len
(
inp
.
clients
()
>
1
):
raise
InconsistencyError
()
app2
=
inp
.
owner
inp_idx2
=
app2
.
outputs
.
index
(
inp
)
d
=
getattr
(
app2
,
'destroy_map'
,
{})
.
get
(
inp_idx2
,
[])
v
=
getattr
(
app2
,
'view_map'
,
{})
.
get
(
inp_idx2
,
[])
dv
=
d
+
v
assert
len
(
dv
)
<=
1
if
len
(
v
)
>
0
:
raise
InconsistencyError
()
if
len
(
inp
.
clients
)
>
1
:
self
.
fail_validate
=
theano
.
gof
.
InconsistencyError
(
"Destroyed variable has too many clients"
)
else
:
app2
=
inp
.
owner
inp_idx2
=
app2
.
outputs
.
index
(
inp
)
d
=
getattr
(
app2
,
'destroy_map'
,
{})
.
get
(
inp_idx2
,
[])
v
=
getattr
(
app2
,
'view_map'
,
{})
.
get
(
inp_idx2
,
[])
dv
=
d
+
v
assert
len
(
dv
)
<=
1
if
len
(
v
)
>
0
:
self
.
fail_validate
=
theano
.
gof
.
InconsistencyError
(
"Destroyed variable has destroy_map or view_map"
)
def
on_import
(
self
,
fgraph
,
app
,
reason
):
"""
...
...
@@ -822,7 +827,8 @@ class DestroyHandler(toolbox.Bookkeeper): # noqa
if
getattr
(
app
.
op
,
'destroy_map'
,
{}):
# TODO: check here only one level of fast destroy_map.
self
.
destroyers
.
add
(
app
)
self
.
fast_destroy
(
app
)
if
config
.
disbale_cycle_detection
:
self
.
fast_destroy
(
app
)
# add this symbol to the forward and backward maps
for
o_idx
,
i_idx_list
in
iteritems
(
getattr
(
app
.
op
,
'view_map'
,
{})):
...
...
@@ -924,7 +930,8 @@ class DestroyHandler(toolbox.Bookkeeper): # noqa
self
.
view_o
.
setdefault
(
new_r
,
OrderedSet
())
.
add
(
output
)
# TODO: check here only one level of fast destroy_map.
self
.
fast_destroy
(
app
)
if
config
.
disbale_cycle_detection
:
self
.
fast_destroy
(
app
)
self
.
stale_droot
=
True
def
validate
(
self
,
fgraph
):
...
...
@@ -937,8 +944,11 @@ class DestroyHandler(toolbox.Bookkeeper): # noqa
"""
if
self
.
destroyers
:
if
config
.
disbale_cycle_detection
and
self
.
fail_validate
:
self
.
fail_validate
=
False
# raise self.fail_validate
InconsistencyError
(
"error"
)
ords
=
self
.
orderings
(
fgraph
)
if
_contains_cycle
(
fgraph
,
ords
):
raise
InconsistencyError
(
"Dependency graph contains cycles"
)
else
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论