Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
62508f2d
提交
62508f2d
authored
4月 04, 2012
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add config.time_eq_optimizer
Like config.time_seq_optimizer, prints timing information on EquilibriumOptimizer. Also change a little bit how config.time_seq_optimizer prints some informations.
上级
c1366d70
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
42 行增加
和
1 行删除
+42
-1
opt.py
theano/gof/opt.py
+42
-1
没有找到文件。
theano/gof/opt.py
浏览文件 @
62508f2d
...
@@ -29,6 +29,11 @@ AddConfigVar('time_seq_optimizer',
...
@@ -29,6 +29,11 @@ AddConfigVar('time_seq_optimizer',
BoolParam
(
False
),
BoolParam
(
False
),
in_c_key
=
False
)
in_c_key
=
False
)
AddConfigVar
(
'time_eq_optimizer'
,
"Should EquilibriumOptimizer print the time taken by each optimizer"
,
BoolParam
(
False
),
in_c_key
=
False
)
import
destroyhandler
as
dh
import
destroyhandler
as
dh
import
traceback
import
traceback
...
@@ -174,7 +179,10 @@ class SeqOptimizer(Optimizer, list):
...
@@ -174,7 +179,10 @@ class SeqOptimizer(Optimizer, list):
if
a
[
0
]
<
b
[
0
]:
return
-
1
if
a
[
0
]
<
b
[
0
]:
return
-
1
return
1
return
1
lll
.
sort
(
cmp
)
lll
.
sort
(
cmp
)
print
lll
for
(
t
,
opt
)
in
lll
[::
-
1
]:
print
'
%.6
fs -
%
s'
%
(
t
,
opt
)
print
def
__eq__
(
self
,
other
):
def
__eq__
(
self
,
other
):
#added to override the list's __eq__ implementation
#added to override the list's __eq__ implementation
...
@@ -1115,7 +1123,12 @@ class EquilibriumOptimizer(NavigatorOptimizer):
...
@@ -1115,7 +1123,12 @@ class EquilibriumOptimizer(NavigatorOptimizer):
process_count
=
{}
process_count
=
{}
max_nb_nodes
=
0
max_nb_nodes
=
0
loop_timing
=
[]
global_opt_timing
=
[]
nb_nodes
=
[]
while
changed
and
not
max_use_abort
:
while
changed
and
not
max_use_abort
:
t0
=
time
.
time
()
changed
=
False
changed
=
False
#apply global optimizer
#apply global optimizer
...
@@ -1125,12 +1138,15 @@ class EquilibriumOptimizer(NavigatorOptimizer):
...
@@ -1125,12 +1138,15 @@ class EquilibriumOptimizer(NavigatorOptimizer):
if
env
.
change_tracker
.
changed
:
if
env
.
change_tracker
.
changed
:
changed
=
True
changed
=
True
global_opt_timing
.
append
(
float
(
time
.
time
()
-
t0
))
#apply local optimizer
#apply local optimizer
for
node
in
start_from
:
for
node
in
start_from
:
assert
node
in
env
.
outputs
assert
node
in
env
.
outputs
q
=
deque
(
graph
.
io_toposort
(
env
.
inputs
,
start_from
))
q
=
deque
(
graph
.
io_toposort
(
env
.
inputs
,
start_from
))
nb_nodes
.
append
(
len
(
q
))
max_nb_nodes
=
max
(
max_nb_nodes
,
len
(
q
))
max_nb_nodes
=
max
(
max_nb_nodes
,
len
(
q
))
max_use
=
max_nb_nodes
*
self
.
max_use_ratio
max_use
=
max_nb_nodes
*
self
.
max_use_ratio
def
importer
(
node
):
def
importer
(
node
):
...
@@ -1163,12 +1179,37 @@ class EquilibriumOptimizer(NavigatorOptimizer):
...
@@ -1163,12 +1179,37 @@ class EquilibriumOptimizer(NavigatorOptimizer):
finally
:
finally
:
self
.
detach_updater
(
env
,
u
)
self
.
detach_updater
(
env
,
u
)
self
.
detach_updater
(
env
,
u
)
#TODO: erase this line, it's redundant at best
self
.
detach_updater
(
env
,
u
)
#TODO: erase this line, it's redundant at best
loop_timing
.
append
(
float
(
time
.
time
()
-
t0
))
if
max_use_abort
:
if
max_use_abort
:
_logger
.
error
(
"EquilibriumOptimizer max'ed out by '
%
s'"
%
opt_name
_logger
.
error
(
"EquilibriumOptimizer max'ed out by '
%
s'"
%
opt_name
+
". You can safely raise the current threshold of "
+
". You can safely raise the current threshold of "
+
"
%
f with the theano flag 'optdb.max_use_ratio'."
%
+
"
%
f with the theano flag 'optdb.max_use_ratio'."
%
config
.
optdb
.
max_use_ratio
)
config
.
optdb
.
max_use_ratio
)
if
config
.
time_eq_optimizer
:
print
"EquilibriumOptimizer"
,
print
getattr
(
self
,
"name"
,
getattr
(
self
,
"__name__"
,
""
))
print
" time
%.3
fs for
%
d passes,
%
d nodes max"
%
(
sum
(
loop_timing
),
len
(
loop_timing
),
max_nb_nodes
)
for
i
in
range
(
len
(
loop_timing
)):
print
'
%
d -
%.3
fs (
%.3
fs in global opts) -
%
d nodes'
%
(
i
,
loop_timing
[
i
],
global_opt_timing
[
i
],
nb_nodes
[
i
])
print
count_opt
=
[]
for
opt
,
count
in
process_count
.
iteritems
():
if
count
>
0
:
count_opt
.
append
((
count
,
opt
))
if
count_opt
:
print
'times applied - optimizer:'
count_opt
.
sort
()
for
(
count
,
opt
)
in
count_opt
[::
-
1
]:
print
'
%
d -
%
s'
%
(
count
,
opt
)
print
def
print_summary
(
self
,
stream
=
sys
.
stdout
,
level
=
0
,
depth
=-
1
):
def
print_summary
(
self
,
stream
=
sys
.
stdout
,
level
=
0
,
depth
=-
1
):
name
=
getattr
(
self
,
'name'
,
None
)
name
=
getattr
(
self
,
'name'
,
None
)
print
>>
stream
,
"
%
s
%
s
%
s id=
%
i"
%
(
' '
*
level
,
self
.
__class__
.
__name__
,
name
,
id
(
self
))
print
>>
stream
,
"
%
s
%
s
%
s id=
%
i"
%
(
' '
*
level
,
self
.
__class__
.
__name__
,
name
,
id
(
self
))
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论