Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
a552d638
提交
a552d638
authored
2月 16, 2017
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make the SequenceOptimizer still have its profile printed when there is an error.
上级
acd4a90f
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
69 行增加
和
48 行删除
+69
-48
function_module.py
theano/compile/function_module.py
+26
-13
opt.py
theano/gof/opt.py
+43
-35
没有找到文件。
theano/compile/function_module.py
浏览文件 @
a552d638
...
...
@@ -1466,6 +1466,10 @@ class FunctionMaker(object):
theano
.
config
.
traceback
.
limit
=
theano
.
config
.
traceback
.
compile_limit
start_optimizer
=
time
.
time
()
# In case there is an error during optimization.
optimizer_profile
=
None
opt_time
=
None
# now optimize the graph
if
theano
.
config
.
cache_optimizations
:
optimizer_profile
=
self
.
optimize_graph_with_cache
(
...
...
@@ -1475,8 +1479,23 @@ class FunctionMaker(object):
end_optimizer
=
time
.
time
()
opt_time
=
end_optimizer
-
start_optimizer
_logger
.
debug
(
'Optimizing took
%
f seconds'
,
opt_time
)
# Add deep copy to respect the memory interface
insert_deepcopy
(
fgraph
,
inputs
,
outputs
+
additional_outputs
)
finally
:
theano
.
config
.
compute_test_value
=
compute_test_value_orig
theano
.
config
.
traceback
.
limit
=
limit_orig
# If the optimizer got interrupted
if
opt_time
is
None
:
end_optimizer
=
time
.
time
()
opt_time
=
end_optimizer
-
start_optimizer
theano
.
compile
.
profiling
.
total_graph_opt_time
+=
opt_time
if
profile
:
if
(
optimizer_profile
is
None
and
hasattr
(
optimizer
,
'pre_profile'
)):
optimizer_profile
=
optimizer
.
pre_profile
profile
.
optimizer_time
+=
opt_time
if
theano
.
config
.
profile_optimizer
:
profile
.
optimizer_profile
=
(
optimizer
,
...
...
@@ -1485,13 +1504,6 @@ class FunctionMaker(object):
warnings
.
warn
((
"config.profile_optimizer requires config.profile to "
" be set to True as well"
),
stacklevel
=
3
)
_logger
.
debug
(
'Optimizing took
%
f seconds'
,
opt_time
)
# Add deep copy to respect the memory interface
insert_deepcopy
(
fgraph
,
inputs
,
outputs
+
additional_outputs
)
finally
:
theano
.
config
.
compute_test_value
=
compute_test_value_orig
theano
.
config
.
traceback
.
limit
=
limit_orig
# initialize the linker
if
not
hasattr
(
linker
,
'accept'
):
...
...
@@ -1783,7 +1795,7 @@ def orig_function(inputs, outputs, mode=None, accept_inplace=False,
if
isinstance
(
mode
,
(
list
,
tuple
)):
# "mode comparison" semantics
raise
Exception
(
"We do not support the passing of multiple modes"
)
else
:
try
:
Maker
=
getattr
(
mode
,
'function_maker'
,
FunctionMaker
)
fn
=
Maker
(
inputs
,
outputs
,
...
...
@@ -1793,11 +1805,12 @@ def orig_function(inputs, outputs, mode=None, accept_inplace=False,
on_unused_input
=
on_unused_input
,
output_keys
=
output_keys
)
.
create
(
defaults
)
t2
=
time
.
time
()
if
profile
:
profile
.
compile_time
+=
t2
-
t1
profile
.
nb_nodes
=
len
(
fn
.
maker
.
fgraph
.
apply_nodes
)
finally
:
t2
=
time
.
time
()
if
profile
:
profile
.
compile_time
+=
t2
-
t1
# TODO: append
profile
.
nb_nodes
=
len
(
fn
.
maker
.
fgraph
.
apply_nodes
)
fn
.
name
=
name
fn
.
maker
.
fgraph
.
name
=
name
...
...
theano/gof/opt.py
浏览文件 @
a552d638
...
...
@@ -228,45 +228,53 @@ class SeqOptimizer(Optimizer, list):
nb_node_before
=
len
(
fgraph
.
apply_nodes
)
sub_profs
=
[]
nb_nodes
=
[]
for
optimizer
in
self
:
try
:
nb_nodes_before
=
len
(
fgraph
.
apply_nodes
)
t0
=
time
.
time
()
sub_prof
=
optimizer
.
optimize
(
fgraph
)
l
.
append
(
float
(
time
.
time
()
-
t0
))
sub_profs
.
append
(
sub_prof
)
nb_nodes
.
append
((
nb_nodes_before
,
len
(
fgraph
.
apply_nodes
)))
if
fgraph
.
profile
:
sub_validate_time
.
append
(
fgraph
.
profile
.
validate_time
)
except
AssertionError
:
# do not catch Assertion failures
raise
except
Exception
as
e
:
if
self
.
failure_callback
:
self
.
failure_callback
(
e
,
self
,
optimizer
)
continue
else
:
raise
if
fgraph
.
profile
:
validate_time
=
fgraph
.
profile
.
validate_time
-
validate_before
callbacks_time
=
{}
for
k
,
v
in
iteritems
(
fgraph
.
execute_callbacks_times
):
if
k
in
callbacks_before
:
t
=
v
-
callbacks_before
[
k
]
if
t
>
0
:
callbacks_time
[
k
]
=
t
else
:
callbacks_time
[
k
]
=
v
else
:
validate_time
=
None
callbacks_time
=
{}
self
.
pre_profile
=
(
self
,
l
,
-
1
,
-
1
,
nb_node_before
,
-
1
,
sub_profs
,
sub_validate_time
,
nb_nodes
,
{})
try
:
for
optimizer
in
self
:
try
:
nb_nodes_before
=
len
(
fgraph
.
apply_nodes
)
t0
=
time
.
time
()
sub_prof
=
optimizer
.
optimize
(
fgraph
)
l
.
append
(
float
(
time
.
time
()
-
t0
))
sub_profs
.
append
(
sub_prof
)
nb_nodes
.
append
((
nb_nodes_before
,
len
(
fgraph
.
apply_nodes
)))
if
fgraph
.
profile
:
sub_validate_time
.
append
(
fgraph
.
profile
.
validate_time
)
except
AssertionError
:
# do not catch Assertion failures
raise
except
Exception
as
e
:
if
self
.
failure_callback
:
self
.
failure_callback
(
e
,
self
,
optimizer
)
continue
else
:
raise
finally
:
callback_time
=
fgraph
.
execute_callbacks_time
-
callback_before
return
(
self
,
l
,
validate_time
,
callback_time
,
nb_node_before
,
if
fgraph
.
profile
:
validate_time
=
fgraph
.
profile
.
validate_time
-
validate_before
callbacks_time
=
{}
for
k
,
v
in
iteritems
(
fgraph
.
execute_callbacks_times
):
if
k
in
callbacks_before
:
t
=
v
-
callbacks_before
[
k
]
if
t
>
0
:
callbacks_time
[
k
]
=
t
else
:
callbacks_time
[
k
]
=
v
else
:
validate_time
=
None
callbacks_time
=
{}
callback_time
=
fgraph
.
execute_callbacks_time
-
callback_before
self
.
pre_profile
=
(
self
,
l
,
validate_time
,
callback_time
,
nb_node_before
,
len
(
fgraph
.
apply_nodes
),
sub_profs
,
sub_validate_time
,
nb_nodes
,
callbacks_time
)
return
self
.
pre_profile
def
__str__
(
self
):
return
"SeqOpt(
%
s)"
%
list
.
__str__
(
self
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论