Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
7ea29681
提交
7ea29681
authored
5月 03, 2013
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add the theano flag profiling.{n_apply,n_ops,min_memory_size}
上级
7f25e754
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
47 行增加
和
4 行删除
+47
-4
config.txt
doc/library/config.txt
+19
-0
profiling.py
theano/compile/profiling.py
+28
-4
没有找到文件。
doc/library/config.txt
浏览文件 @
7ea29681
...
@@ -286,6 +286,25 @@ import theano and print the config variable, as in:
...
@@ -286,6 +286,25 @@ import theano and print the config variable, as in:
Do the vm/cvm linkers profile the optimization phase when compiling a Theano function?
Do the vm/cvm linkers profile the optimization phase when compiling a Theano function?
It only work when profile=True.
It only work when profile=True.
.. attribute:: profiling.n_apply
Positive int value, default: 20.
The number of apply node to print in the profiler output
.. attribute:: profiling.n_ops
Positive int value, default: 20.
The number of ops to print in the profiler output
.. attribute:: profiling.min_memory_size
Positive int value, default: 1024.
For the memory profile, do not print apply nodes if the size
of their outputs (in bytes) is lower then this.
.. attribute:: config.lib.amdlibm
.. attribute:: config.lib.amdlibm
Bool value: either True or False
Bool value: either True or False
...
...
theano/compile/profiling.py
浏览文件 @
7ea29681
...
@@ -23,7 +23,8 @@ import time
...
@@ -23,7 +23,8 @@ import time
import
numpy
import
numpy
import
theano
import
theano
from
theano.configparser
import
AddConfigVar
,
BoolParam
from
theano.configparser
import
AddConfigVar
,
BoolParam
,
IntParam
import_time
=
time
.
time
()
import_time
=
time
.
time
()
config
=
theano
.
config
config
=
theano
.
config
...
@@ -35,6 +36,22 @@ AddConfigVar('profiling.time_thunks',
...
@@ -35,6 +36,22 @@ AddConfigVar('profiling.time_thunks',
"""Time individual thunks when profiling"""
,
"""Time individual thunks when profiling"""
,
BoolParam
(
True
))
BoolParam
(
True
))
AddConfigVar
(
'profiling.n_apply'
,
"Number of apply instances to print by default"
,
IntParam
(
20
,
lambda
i
:
i
>
0
),
in_c_key
=
False
)
AddConfigVar
(
'profiling.n_ops'
,
"Number of ops to print by default"
,
IntParam
(
20
,
lambda
i
:
i
>
0
),
in_c_key
=
False
)
AddConfigVar
(
'profiling.min_memory_size'
,
"""For the memory profile, do not print apply nodes if the size
of their outputs (in bytes) is lower then this threshold"""
,
IntParam
(
1024
,
lambda
i
:
i
>=
0
),
in_c_key
=
False
)
def
_atexit_print_fn
():
def
_atexit_print_fn
():
"""Print ProfileStat objects in _atexit_print_list to _atexit_print_file
"""Print ProfileStat objects in _atexit_print_list to _atexit_print_file
...
@@ -42,7 +59,9 @@ def _atexit_print_fn():
...
@@ -42,7 +59,9 @@ def _atexit_print_fn():
printed
=
0
printed
=
0
for
ps
in
_atexit_print_list
:
for
ps
in
_atexit_print_list
:
if
ps
.
fct_callcount
or
ps
.
compile_time
>
0
:
if
ps
.
fct_callcount
or
ps
.
compile_time
>
0
:
ps
.
summary
(
file
=
_atexit_print_file
)
ps
.
summary
(
file
=
_atexit_print_file
,
n_ops_to_print
=
config
.
profiling
.
n_ops
,
n_apply_to_print
=
config
.
profiling
.
n_apply
)
printed
+=
1
printed
+=
1
else
:
else
:
print
'Skipping empty Profile'
print
'Skipping empty Profile'
...
@@ -74,7 +93,9 @@ def _atexit_print_fn():
...
@@ -74,7 +93,9 @@ def _atexit_print_fn():
else
:
else
:
cum
.
optimizer_profile
=
None
cum
.
optimizer_profile
=
None
cum
.
summary
(
file
=
_atexit_print_file
)
cum
.
summary
(
file
=
_atexit_print_file
,
n_ops_to_print
=
config
.
profiling
.
n_ops
,
n_apply_to_print
=
config
.
profiling
.
n_apply
)
atexit
.
register
(
_atexit_print_fn
)
atexit
.
register
(
_atexit_print_fn
)
...
@@ -729,7 +750,7 @@ class ProfileStats(object):
...
@@ -729,7 +750,7 @@ class ProfileStats(object):
items
=
node_mem
.
items
()
items
=
node_mem
.
items
()
items
.
sort
(
key
=
lambda
a
:
a
[
1
])
items
.
sort
(
key
=
lambda
a
:
a
[
1
])
items
.
reverse
()
items
.
reverse
()
for
node
,
node_outputs_size
in
items
[:
N
]
:
for
idx
,
(
node
,
node_outputs_size
)
in
enumerate
(
items
[:
N
])
:
code
=
[
'c'
]
*
len
(
node
.
outputs
)
code
=
[
'c'
]
*
len
(
node
.
outputs
)
for
out
,
inp
in
getattr
(
node
.
op
,
'destroy_map'
,
{})
.
iteritems
():
for
out
,
inp
in
getattr
(
node
.
op
,
'destroy_map'
,
{})
.
iteritems
():
code
[
out
]
=
"i"
code
[
out
]
=
"i"
...
@@ -740,6 +761,9 @@ class ProfileStats(object):
...
@@ -740,6 +761,9 @@ class ProfileStats(object):
if
all
([
hasattr
(
out
.
type
,
'get_size'
)
if
all
([
hasattr
(
out
.
type
,
'get_size'
)
for
out
in
node
.
outputs
]):
for
out
in
node
.
outputs
]):
size
=
"
%9
dB"
%
node_outputs_size
size
=
"
%9
dB"
%
node_outputs_size
if
node_outputs_size
<
config
.
profiling
.
min_memory_size
:
N
=
idx
break
else
:
else
:
size
=
"
%10
s"
%
"Unknown"
size
=
"
%10
s"
%
"Unknown"
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论