Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
ddb24d79
提交
ddb24d79
authored
7月 03, 2014
作者:
Hengjean
提交者:
Frederic
10月 21, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Using temporary pickle to debug. Refactored lambda expressions used in history.…
Using temporary pickle to debug. Refactored lambda expressions used in history. Refactored problematic Opt.
上级
0e773298
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
33 行增加
和
9 行删除
+33
-9
function_module.py
theano/compile/function_module.py
+6
-5
toolbox.py
theano/gof/toolbox.py
+27
-4
没有找到文件。
theano/compile/function_module.py
浏览文件 @
ddb24d79
...
@@ -1079,9 +1079,9 @@ class FunctionMaker(object):
...
@@ -1079,9 +1079,9 @@ class FunctionMaker(object):
opt_time: timing
opt_time: timing
'''
'''
from
theano.gof.compilelock
import
get_lock
,
release_lock
from
theano.gof.compilelock
import
get_lock
,
release_lock
import
cP
ickle
import
p
ickle
import
os.path
import
os.path
graph_db_file
=
theano
.
config
.
compiledir
+
'/optimized_graphs.pkl'
graph_db_file
=
os
.
path
.
join
(
theano
.
config
.
compiledir
,
'optimized_graphs.pkl'
)
# the inputs, outputs, and size of the graph to be optimized
# the inputs, outputs, and size of the graph to be optimized
inputs_new
=
fgraph
.
inputs
inputs_new
=
fgraph
.
inputs
outputs_new
=
fgraph
.
outputs
outputs_new
=
fgraph
.
outputs
...
@@ -1101,10 +1101,11 @@ class FunctionMaker(object):
...
@@ -1101,10 +1101,11 @@ class FunctionMaker(object):
# load the graph_db dictionary
# load the graph_db dictionary
try
:
try
:
graph_db
=
cP
ickle
.
load
(
f
)
graph_db
=
p
ickle
.
load
(
f
)
print
'graph_db is not empty'
print
'graph_db is not empty'
except
EOFError
:
except
EOFError
,
e
:
# the file has nothing in it
# the file has nothing in it
print
e
print
'graph_db is empty'
print
'graph_db is empty'
graph_db
=
{}
graph_db
=
{}
...
@@ -1180,7 +1181,7 @@ class FunctionMaker(object):
...
@@ -1180,7 +1181,7 @@ class FunctionMaker(object):
cPickle.load(test_file)
cPickle.load(test_file)
'''
'''
graph_db
.
update
({
before_opt
:
fgraph
})
graph_db
.
update
({
before_opt
:
fgraph
})
cP
ickle
.
dump
(
graph_db
,
f
,
-
1
)
p
ickle
.
dump
(
graph_db
,
f
,
-
1
)
print
'saved into graph_db'
print
'saved into graph_db'
else
:
else
:
print
'no opt, get graph from graph_db'
print
'no opt, get graph from graph_db'
...
...
theano/gof/toolbox.py
浏览文件 @
ddb24d79
...
@@ -104,6 +104,30 @@ class Bookkeeper(Feature):
...
@@ -104,6 +104,30 @@ class Bookkeeper(Feature):
self
.
on_prune
(
fgraph
,
node
,
'Bookkeeper.detach'
)
self
.
on_prune
(
fgraph
,
node
,
'Bookkeeper.detach'
)
class
getCheckpoint
:
def
__init__
(
self
,
history
,
fgraph
):
self
.
h
=
history
self
.
fgraph
=
fgraph
def
__call__
(
self
):
return
len
(
self
.
h
.
history
[
self
.
fgraph
])
class
lambdextract
:
def
__init__
(
self
,
fgraph
,
node
,
i
,
r
,
reason
=
None
):
self
.
fgraph
=
fgraph
self
.
node
=
node
self
.
i
=
i
self
.
r
=
r
self
.
reason
=
reason
def
__call__
(
self
):
return
self
.
fgraph
.
change_input
(
self
.
node
,
self
.
i
,
self
.
r
,
reason
=
(
"Revert"
,
self
.
reason
))
class
History
(
Feature
):
class
History
(
Feature
):
pickle_rm_attr
=
[
"checkpoint"
,
"revert"
]
pickle_rm_attr
=
[
"checkpoint"
,
"revert"
]
...
@@ -118,11 +142,11 @@ class History(Feature):
...
@@ -118,11 +142,11 @@ class History(Feature):
# Don't call unpickle here, as ReplaceValidate.on_attach()
# Don't call unpickle here, as ReplaceValidate.on_attach()
# call to History.on_attach() will call the
# call to History.on_attach() will call the
# ReplaceValidate.unpickle and not History.unpickle
# ReplaceValidate.unpickle and not History.unpickle
fgraph
.
checkpoint
=
lambda
:
len
(
self
.
history
[
fgraph
]
)
fgraph
.
checkpoint
=
getCheckpoint
(
self
,
fgraph
)
fgraph
.
revert
=
partial
(
self
.
revert
,
fgraph
)
fgraph
.
revert
=
partial
(
self
.
revert
,
fgraph
)
def
unpickle
(
self
,
fgraph
):
def
unpickle
(
self
,
fgraph
):
fgraph
.
checkpoint
=
lambda
:
len
(
self
.
history
[
fgraph
]
)
fgraph
.
checkpoint
=
getCheckpoint
(
self
,
fgraph
)
fgraph
.
revert
=
partial
(
self
.
revert
,
fgraph
)
fgraph
.
revert
=
partial
(
self
.
revert
,
fgraph
)
def
on_detach
(
self
,
fgraph
):
def
on_detach
(
self
,
fgraph
):
...
@@ -134,8 +158,7 @@ class History(Feature):
...
@@ -134,8 +158,7 @@ class History(Feature):
if
self
.
history
[
fgraph
]
is
None
:
if
self
.
history
[
fgraph
]
is
None
:
return
return
h
=
self
.
history
[
fgraph
]
h
=
self
.
history
[
fgraph
]
h
.
append
(
lambda
:
fgraph
.
change_input
(
node
,
i
,
r
,
h
.
append
(
lambdextract
(
fgraph
,
node
,
i
,
r
,
reason
))
reason
=
(
"Revert"
,
reason
)))
def
revert
(
self
,
fgraph
,
checkpoint
):
def
revert
(
self
,
fgraph
,
checkpoint
):
"""
"""
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论