Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
9e501182
提交
9e501182
authored
5月 28, 2012
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add the printing of replace_all_validate with the flag time_seq_optimizer.
上级
f7ca8364
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
11 行增加
和
2 行删除
+11
-2
opt.py
theano/gof/opt.py
+3
-1
toolbox.py
theano/gof/toolbox.py
+8
-1
没有找到文件。
theano/gof/opt.py
浏览文件 @
9e501182
...
@@ -154,6 +154,7 @@ class SeqOptimizer(Optimizer, list):
...
@@ -154,6 +154,7 @@ class SeqOptimizer(Optimizer, list):
Applies each L{Optimizer} in self in turn.
Applies each L{Optimizer} in self in turn.
"""
"""
l
=
[]
l
=
[]
replace_all_validate_before
=
env
.
replace_all_validate_time
nb_node_before
=
len
(
env
.
nodes
)
nb_node_before
=
len
(
env
.
nodes
)
for
optimizer
in
self
:
for
optimizer
in
self
:
try
:
try
:
...
@@ -174,7 +175,8 @@ class SeqOptimizer(Optimizer, list):
...
@@ -174,7 +175,8 @@ class SeqOptimizer(Optimizer, list):
if
hasattr
(
self
,
"name"
):
print
self
.
name
,
if
hasattr
(
self
,
"name"
):
print
self
.
name
,
elif
hasattr
(
self
,
"__name__"
):
print
self
.
__name__
,
elif
hasattr
(
self
,
"__name__"
):
print
self
.
__name__
,
print
" time
%.3
fs for
%
d/
%
d nodes before/after optimization"
%
(
sum
(
l
),
nb_node_before
,
len
(
env
.
nodes
))
print
" time
%.3
fs for
%
d/
%
d nodes before/after optimization"
%
(
sum
(
l
),
nb_node_before
,
len
(
env
.
nodes
))
print
" time
%.3
fs for replace_all_validate "
%
(
env
.
replace_all_validate_time
-
replace_all_validate_before
)
ll
=
[]
ll
=
[]
for
opt
in
self
:
for
opt
in
self
:
if
hasattr
(
opt
,
"__name__"
):
if
hasattr
(
opt
,
"__name__"
):
...
...
theano/gof/toolbox.py
浏览文件 @
9e501182
import
sys
import
sys
import
time
from
theano.gof.python25
import
partial
from
theano.gof.python25
import
partial
...
@@ -85,23 +86,27 @@ class ReplaceValidate(History, Validator):
...
@@ -85,23 +86,27 @@ class ReplaceValidate(History, Validator):
def
on_attach
(
self
,
env
):
def
on_attach
(
self
,
env
):
History
.
on_attach
(
self
,
env
)
History
.
on_attach
(
self
,
env
)
Validator
.
on_attach
(
self
,
env
)
Validator
.
on_attach
(
self
,
env
)
for
attr
in
(
'replace_validate'
,
'replace_all_validate'
):
for
attr
in
(
'replace_validate'
,
'replace_all_validate'
,
'replace_all_validate_time'
):
if
hasattr
(
env
,
attr
):
if
hasattr
(
env
,
attr
):
raise
AlreadyThere
(
"ReplaceValidate feature is already present"
raise
AlreadyThere
(
"ReplaceValidate feature is already present"
" or in conflict with another plugin."
)
" or in conflict with another plugin."
)
env
.
replace_validate
=
partial
(
self
.
replace_validate
,
env
)
env
.
replace_validate
=
partial
(
self
.
replace_validate
,
env
)
env
.
replace_all_validate
=
partial
(
self
.
replace_all_validate
,
env
)
env
.
replace_all_validate
=
partial
(
self
.
replace_all_validate
,
env
)
env
.
replace_all_validate_time
=
0
def
on_detach
(
self
,
env
):
def
on_detach
(
self
,
env
):
History
.
on_detach
(
self
,
env
)
History
.
on_detach
(
self
,
env
)
Validator
.
on_detach
(
self
,
env
)
Validator
.
on_detach
(
self
,
env
)
del
env
.
replace_validate
del
env
.
replace_validate
del
env
.
replace_all_validate
del
env
.
replace_all_validate
del
env
.
replace_all_validate_time
def
replace_validate
(
self
,
env
,
r
,
new_r
,
reason
=
None
):
def
replace_validate
(
self
,
env
,
r
,
new_r
,
reason
=
None
):
self
.
replace_all_validate
(
env
,
[(
r
,
new_r
)],
reason
=
reason
)
self
.
replace_all_validate
(
env
,
[(
r
,
new_r
)],
reason
=
reason
)
def
replace_all_validate
(
self
,
env
,
replacements
,
reason
=
None
):
def
replace_all_validate
(
self
,
env
,
replacements
,
reason
=
None
):
t0
=
time
.
time
()
chk
=
env
.
checkpoint
()
chk
=
env
.
checkpoint
()
for
r
,
new_r
in
replacements
:
for
r
,
new_r
in
replacements
:
try
:
try
:
...
@@ -121,6 +126,8 @@ class ReplaceValidate(History, Validator):
...
@@ -121,6 +126,8 @@ class ReplaceValidate(History, Validator):
except
Exception
,
e
:
except
Exception
,
e
:
env
.
revert
(
chk
)
env
.
revert
(
chk
)
raise
raise
t1
=
time
.
time
()
env
.
replace_all_validate_time
+=
t1
-
t0
class
NodeFinder
(
dict
,
Bookkeeper
):
class
NodeFinder
(
dict
,
Bookkeeper
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论