Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
be890125
提交
be890125
authored
11月 30, 2012
作者:
Ian Goodfellow
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
made functiongraph more deterministic
上级
42116a64
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
45 行增加
和
3 行删除
+45
-3
fg.py
theano/gof/fg.py
+45
-3
没有找到文件。
theano/gof/fg.py
浏览文件 @
be890125
...
@@ -12,6 +12,9 @@ from python25 import all
...
@@ -12,6 +12,9 @@ from python25 import all
from
theano
import
config
from
theano
import
config
import
warnings
import
warnings
NullType
=
None
NullType
=
None
import
theano
from
python25
import
OrderedDict
from
theano.misc.ordered_set
import
OrderedSet
class
InconsistencyError
(
Exception
):
class
InconsistencyError
(
Exception
):
"""
"""
...
@@ -553,10 +556,44 @@ class FunctionGraph(utils.object2):
...
@@ -553,10 +556,44 @@ class FunctionGraph(utils.object2):
# 1-element graphs.
# 1-element graphs.
return
list
(
self
.
apply_nodes
)
return
list
(
self
.
apply_nodes
)
fg
=
self
fg
=
self
if
verbose
:
print
'FunctionGraph.toposort multinode'
# DEBUGGING NOTE: this might be the source of non-determinism.
# it definitely contains dicts and lists made
# by iterating over dicts.
# does it affect the final sort order though?
ords
=
self
.
orderings
()
ords
=
self
.
orderings
()
if
verbose
:
"""
print 'FunctionGraph inputs'
assert isinstance(fg.inputs, list)
for i, elem in enumerate(fg.inputs):
print '
\t
%
d:'
%
i
print theano.printing.min_informative_str(elem, indent_level=1)
print 'FunctionGraph outputs'
assert isinstance(fg.outputs, list)
for i, elem in enumerate(fg.outputs):
print '
\t
%
d:'
%
i
print theano.printing.min_informative_str(elem, indent_level=1)
"""
for
i
,
key
in
enumerate
(
ords
):
print
'orderings'
,
i
print
'
\t
key'
,
i
,
'is'
,
key
v
=
ords
[
key
]
print
'
\t\t
value'
,
i
,
'is a'
,
type
(
v
)
for
j
,
elem
in
enumerate
(
v
):
print
'
\t\t\t
elem'
,
j
,
':'
,
elem
order
=
graph
.
io_toposort
(
fg
.
inputs
,
fg
.
outputs
,
ords
)
order
=
graph
.
io_toposort
(
fg
.
inputs
,
fg
.
outputs
,
ords
)
if
verbose
:
print
'FunctionGraph.toposort returning order:'
for
i
,
elem
in
enumerate
(
order
):
print
'
\t
%
d:'
%
i
,
elem
return
order
return
order
def
orderings
(
self
):
def
orderings
(
self
):
...
@@ -571,14 +608,19 @@ class FunctionGraph(utils.object2):
...
@@ -571,14 +608,19 @@ class FunctionGraph(utils.object2):
take care of computing dependencies by itself.
take care of computing dependencies by itself.
"""
"""
ords
=
{}
ords
=
OrderedDict
()
assert
isinstance
(
self
.
_features
,
list
)
for
feature
in
self
.
_features
:
for
feature
in
self
.
_features
:
if
hasattr
(
feature
,
'orderings'
):
if
hasattr
(
feature
,
'orderings'
):
for
node
,
prereqs
in
feature
.
orderings
(
self
)
.
items
():
orderings
=
feature
.
orderings
(
self
)
if
not
isinstance
(
orderings
,
OrderedDict
):
raise
TypeError
(
"Non-deterministic return value from "
\
+
str
(
feature
.
orderings
)
\
+
". Nondeterministic object is "
+
str
(
orderings
))
ords
.
setdefault
(
node
,
[])
.
extend
(
prereqs
)
ords
.
setdefault
(
node
,
[])
.
extend
(
prereqs
)
# eliminate duplicate prereqs
# eliminate duplicate prereqs
for
(
node
,
prereqs
)
in
ords
.
items
():
for
(
node
,
prereqs
)
in
ords
.
items
():
ords
[
node
]
=
list
(
s
et
(
prereqs
))
ords
[
node
]
=
list
(
OrderedS
et
(
prereqs
))
return
ords
return
ords
def
nclients
(
self
,
r
):
def
nclients
(
self
,
r
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论