Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
d73bfb97
提交
d73bfb97
authored
8月 15, 2016
作者:
sentient07
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Changed the printing structure
上级
c57b0936
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
18 行增加
和
29 行删除
+18
-29
opt.py
theano/gof/opt.py
+18
-29
没有找到文件。
theano/gof/opt.py
浏览文件 @
d73bfb97
...
...
@@ -335,6 +335,12 @@ class SeqOptimizer(Optimizer, list):
if
sub_profs
[
i
]:
opts
[
i
]
.
print_profile
(
stream
,
sub_profs
[
i
],
level
=
level
+
1
)
if
isinstance
(
opts
[
i
],
TopoOptimizer
):
if
isinstance
(
opts
[
i
]
.
local_opt
,
LocalOptGroup
):
lo_g
=
opts
[
i
]
.
local_opt
opts
[
i
]
.
local_opt
.
print_profile
(
stream
,
(
lo_g
.
time_opts
,
lo_g
.
time_nodes
,
lo_g
.
process_count
))
print
(
file
=
stream
)
@staticmethod
...
...
@@ -1260,12 +1266,10 @@ class LocalOptGroup(LocalOptimizer):
assert
len
(
kwargs
)
==
0
self
.
time_opts
=
{}
self
.
time_nodes
=
{}
self
.
node_created
=
{}
self
.
process_count
=
{}
for
o
in
self
.
opts
:
self
.
process_count
.
setdefault
(
o
,
0
)
self
.
node_created
.
setdefault
(
o
,
0
)
self
.
time_opts
.
setdefault
(
o
,
0
)
for
c
in
o
.
tracks
():
self
.
track_map
.
setdefault
(
c
,
[])
.
append
(
o
)
...
...
@@ -1287,16 +1291,6 @@ class LocalOptGroup(LocalOptimizer):
if
len
(
self
.
opts
)
==
0
:
return
# This method is just kept for the `print_profile` method to know the variables that
# needs to be printed
def
apply
(
self
):
import
pdb
pdb
.
set_trace
()
return
(
self
.
time_opts
,
self
.
time_nodes
,
self
.
node_created
,
self
.
process_count
)
def
compute_opts
(
node
):
opts
=
self
.
track_map
.
get
(
type
(
node
.
op
),
[])
opts
+=
self
.
track_map
.
get
(
node
.
op
,
[])
...
...
@@ -1314,7 +1308,6 @@ class LocalOptGroup(LocalOptimizer):
continue
else
:
self
.
time_opts
[
opt
]
=
opt_start
-
opt_finish
self
.
node_created
[
opt
]
+=
len
(
graph
.
ops
(
node
.
inputs
,
node
.
outputs
))
self
.
process_count
[
opt
]
+=
1
if
not
multiple_opts
or
not
repl
[
0
]
.
owner
:
return
repl
...
...
@@ -1333,9 +1326,7 @@ class LocalOptGroup(LocalOptimizer):
@staticmethod
def
print_profile
(
stream
,
prof
,
level
=
0
):
(
time_opts
,
time_nodes
,
node_created
,
process_count
)
=
prof
import
pdb
pdb
.
set_trace
()
(
time_opts
,
time_nodes
,
process_count
)
=
prof
blanc
=
(
' '
*
int
(
level
))
print
(
blanc
,
"LocalOptGroup"
,
file
=
stream
)
count_opt
=
[]
...
...
@@ -1343,22 +1334,18 @@ class LocalOptGroup(LocalOptimizer):
not_used_time
=
0
for
o
,
count
in
iteritems
(
process_count
):
if
count
>
0
:
count_opt
.
append
((
time_opts
[
o
],
count
,
node_created
[
o
],
o
))
count_opt
.
append
((
time_opts
[
o
],
count
,
o
))
else
:
not_used
.
append
((
time_opts
[
o
],
o
))
not_used_time
+=
time_opts
[
o
]
if
count_opt
:
for
i
in
count_opt
:
if
not
"useless"
in
count_opt
[
-
1
]
.
__name__
:
continue
print
(
blanc
,
' times - times applied -
Node created -
name:'
,
' times - times applied - name:'
,
file
=
stream
)
count_opt
.
sort
()
for
(
t
,
count
,
n_created
,
o
)
in
count_opt
[::
-
1
]:
for
(
t
,
count
,
o
)
in
count_opt
[::
-
1
]:
print
(
blanc
,
'
%.3
fs -
%
d -
%
d -
%
s'
%
(
t
,
count
,
n_created
,
o
),
file
=
stream
)
t
,
count
,
o
),
file
=
stream
)
print
(
blanc
,
'
%.3
fs - in
%
d optimization that were not used (display those with runtime greater than 0)'
%
(
not_used_time
,
len
(
not_used
)),
file
=
stream
)
not_used
.
sort
(
key
=
lambda
nu
:
(
nu
[
0
],
str
(
nu
[
1
])))
...
...
@@ -1887,6 +1874,12 @@ class NavigatorOptimizer(Optimizer):
if
u
is
not
None
:
fgraph
.
remove_feature
(
u
)
@staticmethod
def
print_profile
(
stream
,
prof
,
level
=
0
):
import
pdb
pdb
.
set_trace
()
def
process_node
(
self
,
fgraph
,
node
,
lopt
=
None
):
"""
This function will use `lopt` to `transform` the `node`. The
...
...
@@ -1997,7 +1990,6 @@ class TopoOptimizer(NavigatorOptimizer):
if
order
not
in
[
'out_to_in'
,
'in_to_out'
]:
raise
ValueError
(
"order must be 'out_to_in' or 'in_to_out'"
)
self
.
order
=
order
self
.
lopt
=
local_opt
NavigatorOptimizer
.
__init__
(
self
,
local_opt
,
ignore_newtrees
,
failure_callback
)
...
...
@@ -2039,7 +2031,7 @@ class TopoOptimizer(NavigatorOptimizer):
callback_time
=
fgraph
.
execute_callbacks_time
-
callback_before
nb_nodes_end
=
len
(
fgraph
.
apply_nodes
)
return
(
self
,
nb
,
nb_nodes_start
,
nb_nodes_end
,
io_t
,
loop_t
,
callback_time
,
self
.
lopt
)
io_t
,
loop_t
,
callback_time
,
self
.
lo
cal_o
pt
)
@staticmethod
def
print_profile
(
stream
,
prof
,
level
=
0
):
...
...
@@ -2054,9 +2046,6 @@ class TopoOptimizer(NavigatorOptimizer):
print
(
blanc
,
"TopoOptimizer "
,
getattr
(
opt
,
"name"
,
getattr
(
opt
,
"__name__"
,
""
)),
file
=
stream
)
if
getattr
(
opt
,
"name"
,
getattr
(
opt
,
"__name__"
,
""
))
==
'useless'
:
import
pdb
pdb
.
set_trace
()
print
(
blanc
,
" nb_node (start, end, changed)"
,
(
nb_nodes_start
,
nb_nodes_end
,
nb
),
file
=
stream
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论