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):
...
@@ -335,6 +335,12 @@ class SeqOptimizer(Optimizer, list):
if
sub_profs
[
i
]:
if
sub_profs
[
i
]:
opts
[
i
]
.
print_profile
(
stream
,
sub_profs
[
i
],
opts
[
i
]
.
print_profile
(
stream
,
sub_profs
[
i
],
level
=
level
+
1
)
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
)
print
(
file
=
stream
)
@staticmethod
@staticmethod
...
@@ -1260,12 +1266,10 @@ class LocalOptGroup(LocalOptimizer):
...
@@ -1260,12 +1266,10 @@ class LocalOptGroup(LocalOptimizer):
assert
len
(
kwargs
)
==
0
assert
len
(
kwargs
)
==
0
self
.
time_opts
=
{}
self
.
time_opts
=
{}
self
.
time_nodes
=
{}
self
.
time_nodes
=
{}
self
.
node_created
=
{}
self
.
process_count
=
{}
self
.
process_count
=
{}
for
o
in
self
.
opts
:
for
o
in
self
.
opts
:
self
.
process_count
.
setdefault
(
o
,
0
)
self
.
process_count
.
setdefault
(
o
,
0
)
self
.
node_created
.
setdefault
(
o
,
0
)
self
.
time_opts
.
setdefault
(
o
,
0
)
self
.
time_opts
.
setdefault
(
o
,
0
)
for
c
in
o
.
tracks
():
for
c
in
o
.
tracks
():
self
.
track_map
.
setdefault
(
c
,
[])
.
append
(
o
)
self
.
track_map
.
setdefault
(
c
,
[])
.
append
(
o
)
...
@@ -1287,16 +1291,6 @@ class LocalOptGroup(LocalOptimizer):
...
@@ -1287,16 +1291,6 @@ class LocalOptGroup(LocalOptimizer):
if
len
(
self
.
opts
)
==
0
:
if
len
(
self
.
opts
)
==
0
:
return
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
):
def
compute_opts
(
node
):
opts
=
self
.
track_map
.
get
(
type
(
node
.
op
),
[])
opts
=
self
.
track_map
.
get
(
type
(
node
.
op
),
[])
opts
+=
self
.
track_map
.
get
(
node
.
op
,
[])
opts
+=
self
.
track_map
.
get
(
node
.
op
,
[])
...
@@ -1314,7 +1308,6 @@ class LocalOptGroup(LocalOptimizer):
...
@@ -1314,7 +1308,6 @@ class LocalOptGroup(LocalOptimizer):
continue
continue
else
:
else
:
self
.
time_opts
[
opt
]
=
opt_start
-
opt_finish
self
.
time_opts
[
opt
]
=
opt_start
-
opt_finish
self
.
node_created
[
opt
]
+=
len
(
graph
.
ops
(
node
.
inputs
,
node
.
outputs
))
self
.
process_count
[
opt
]
+=
1
self
.
process_count
[
opt
]
+=
1
if
not
multiple_opts
or
not
repl
[
0
]
.
owner
:
if
not
multiple_opts
or
not
repl
[
0
]
.
owner
:
return
repl
return
repl
...
@@ -1333,9 +1326,7 @@ class LocalOptGroup(LocalOptimizer):
...
@@ -1333,9 +1326,7 @@ class LocalOptGroup(LocalOptimizer):
@staticmethod
@staticmethod
def
print_profile
(
stream
,
prof
,
level
=
0
):
def
print_profile
(
stream
,
prof
,
level
=
0
):
(
time_opts
,
time_nodes
,
node_created
,
process_count
)
=
prof
(
time_opts
,
time_nodes
,
process_count
)
=
prof
import
pdb
pdb
.
set_trace
()
blanc
=
(
' '
*
int
(
level
))
blanc
=
(
' '
*
int
(
level
))
print
(
blanc
,
"LocalOptGroup"
,
file
=
stream
)
print
(
blanc
,
"LocalOptGroup"
,
file
=
stream
)
count_opt
=
[]
count_opt
=
[]
...
@@ -1343,22 +1334,18 @@ class LocalOptGroup(LocalOptimizer):
...
@@ -1343,22 +1334,18 @@ class LocalOptGroup(LocalOptimizer):
not_used_time
=
0
not_used_time
=
0
for
o
,
count
in
iteritems
(
process_count
):
for
o
,
count
in
iteritems
(
process_count
):
if
count
>
0
:
if
count
>
0
:
count_opt
.
append
((
time_opts
[
o
],
count
,
count_opt
.
append
((
time_opts
[
o
],
count
,
o
))
node_created
[
o
],
o
))
else
:
else
:
not_used
.
append
((
time_opts
[
o
],
o
))
not_used
.
append
((
time_opts
[
o
],
o
))
not_used_time
+=
time_opts
[
o
]
not_used_time
+=
time_opts
[
o
]
if
count_opt
:
if
count_opt
:
for
i
in
count_opt
:
if
not
"useless"
in
count_opt
[
-
1
]
.
__name__
:
continue
print
(
blanc
,
print
(
blanc
,
' times - times applied -
Node created -
name:'
,
' times - times applied - name:'
,
file
=
stream
)
file
=
stream
)
count_opt
.
sort
()
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'
%
(
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)'
%
(
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_time
,
len
(
not_used
)),
file
=
stream
)
not_used
.
sort
(
key
=
lambda
nu
:
(
nu
[
0
],
str
(
nu
[
1
])))
not_used
.
sort
(
key
=
lambda
nu
:
(
nu
[
0
],
str
(
nu
[
1
])))
...
@@ -1887,6 +1874,12 @@ class NavigatorOptimizer(Optimizer):
...
@@ -1887,6 +1874,12 @@ class NavigatorOptimizer(Optimizer):
if
u
is
not
None
:
if
u
is
not
None
:
fgraph
.
remove_feature
(
u
)
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
):
def
process_node
(
self
,
fgraph
,
node
,
lopt
=
None
):
"""
"""
This function will use `lopt` to `transform` the `node`. The
This function will use `lopt` to `transform` the `node`. The
...
@@ -1997,7 +1990,6 @@ class TopoOptimizer(NavigatorOptimizer):
...
@@ -1997,7 +1990,6 @@ class TopoOptimizer(NavigatorOptimizer):
if
order
not
in
[
'out_to_in'
,
'in_to_out'
]:
if
order
not
in
[
'out_to_in'
,
'in_to_out'
]:
raise
ValueError
(
"order must be 'out_to_in' or 'in_to_out'"
)
raise
ValueError
(
"order must be 'out_to_in' or 'in_to_out'"
)
self
.
order
=
order
self
.
order
=
order
self
.
lopt
=
local_opt
NavigatorOptimizer
.
__init__
(
self
,
local_opt
,
ignore_newtrees
,
NavigatorOptimizer
.
__init__
(
self
,
local_opt
,
ignore_newtrees
,
failure_callback
)
failure_callback
)
...
@@ -2039,7 +2031,7 @@ class TopoOptimizer(NavigatorOptimizer):
...
@@ -2039,7 +2031,7 @@ class TopoOptimizer(NavigatorOptimizer):
callback_time
=
fgraph
.
execute_callbacks_time
-
callback_before
callback_time
=
fgraph
.
execute_callbacks_time
-
callback_before
nb_nodes_end
=
len
(
fgraph
.
apply_nodes
)
nb_nodes_end
=
len
(
fgraph
.
apply_nodes
)
return
(
self
,
nb
,
nb_nodes_start
,
nb_nodes_end
,
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
@staticmethod
def
print_profile
(
stream
,
prof
,
level
=
0
):
def
print_profile
(
stream
,
prof
,
level
=
0
):
...
@@ -2054,9 +2046,6 @@ class TopoOptimizer(NavigatorOptimizer):
...
@@ -2054,9 +2046,6 @@ class TopoOptimizer(NavigatorOptimizer):
print
(
blanc
,
"TopoOptimizer "
,
print
(
blanc
,
"TopoOptimizer "
,
getattr
(
opt
,
"name"
,
getattr
(
opt
,
"__name__"
,
""
)),
file
=
stream
)
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)"
,
(
print
(
blanc
,
" nb_node (start, end, changed)"
,
(
nb_nodes_start
,
nb_nodes_end
,
nb
),
file
=
stream
)
nb_nodes_start
,
nb_nodes_end
,
nb
),
file
=
stream
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论