Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
12e9dd7b
提交
12e9dd7b
authored
1月 29, 2010
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
lower profiler overhead by moving computation into the printing phase instead of…
lower profiler overhead by moving computation into the printing phase instead of the recording phase.
上级
5a0e9943
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
22 行增加
和
43 行删除
+22
-43
profilemode.py
theano/compile/profilemode.py
+22
-43
没有找到文件。
theano/compile/profilemode.py
浏览文件 @
12e9dd7b
...
...
@@ -25,9 +25,7 @@ class Profile_Maker(FunctionMaker):
for
i
,
node
in
enumerate
(
ret
.
maker
.
env
.
toposort
()):
self
.
mode
.
apply_time
[(
i
,
node
.
op
)]
=
0.0
self
.
mode
.
apply_call
[(
i
,
node
.
op
)]
=
0
self
.
mode
.
op_time
[
node
.
op
]
=
0.
# self.mode.op_cimpl[node.op] =
self
.
mode
.
op_call
[
node
.
op
]
=
0
return
ret
...
...
@@ -36,16 +34,14 @@ class ProfileMode(Mode):
local_time
=
[
0.0
]
apply_time
=
{}
apply_call
=
{}
op_time
=
{}
op_cimpl
=
{}
op_call
=
{}
compile_time
=
0
#time passed in theano.function()
fct_call_time
=
{}
#time passed inside theano fct call including op time.
fct_call
=
{}
self
.
__setstate__
((
linker
,
optimizer
,
local_time
,
apply_time
,
apply_call
,
op_
time
,
op_cimpl
,
op_call
,
op_
cimpl
,
compile_time
,
fct_call_time
,
fct_call
))
def
function_maker
(
self
,
i
,
o
,
m
,
*
args
,
**
kwargs
):
...
...
@@ -58,19 +54,17 @@ class ProfileMode(Mode):
#print "__getstate__",self.provided_linker,self.provided_optimizer
return
(
self
.
provided_linker
,
self
.
provided_optimizer
,
self
.
local_time
,
self
.
apply_time
,
self
.
apply_call
,
self
.
op_
time
,
self
.
op_cimpl
,
self
.
op_cal
l
,
self
.
compile_time
,
self
.
fct_call_time
,
self
.
fct_call
)
self
.
op_
cimp
l
,
self
.
compile_time
,
self
.
fct_call_time
,
self
.
fct_call
)
def
__setstate__
(
self
,
(
linker
,
optimizer
,
local_time
,
apply_time
,
apply_call
,
op_
time
,
op_cimpl
,
op_call
,
op_
cimpl
,
compile_time
,
fct_call_time
,
fct_call
)):
self
.
local_time
=
local_time
self
.
apply_time
=
apply_time
self
.
apply_call
=
apply_call
self
.
op_time
=
op_time
self
.
op_cimpl
=
op_cimpl
self
.
op_call
=
op_call
self
.
compile_time
=
compile_time
self
.
fct_call_time
=
fct_call_time
self
.
fct_call
=
fct_call
...
...
@@ -94,9 +88,7 @@ class ProfileMode(Mode):
local_time
[
0
]
+=
dt
apply_time
[(
i
,
node
.
op
)]
+=
dt
apply_call
[(
i
,
node
.
op
)]
+=
1
op_time
[
node
.
op
]
+=
dt
op_cimpl
[
node
.
op
]
=
hasattr
(
th
,
'cthunk'
)
op_call
[
node
.
op
]
+=
1
self
.
provided_linker
=
linker
...
...
@@ -133,18 +125,11 @@ class ProfileMode(Mode):
fct_call
=
self
.
fct_call
apply_time
=
self
.
apply_time
apply_call
=
self
.
apply_call
op_time
=
self
.
op_time
op_call
=
self
.
op_call
op_cimpl
=
self
.
op_cimpl
op_flops
=
{}
for
a
,
t
in
op_time
.
items
():
if
hasattr
(
a
,
'flops'
):
op_flops
[
a
]
=
a
.
flops
*
op_call
[
a
]
/
t
/
1e6
self
.
print_summary_
(
"print_summary"
,
local_time
,
compile_time
,
fct_call_time
,
fct_call
,
apply_time
,
apply_call
,
op_
time
,
op_call
,
op_
cimpl
,
op_flops
,
n_apply_to_print
,
n_ops_to_print
)
apply_time
,
apply_call
,
op_cimpl
,
n_apply_to_print
,
n_ops_to_print
)
def
print_diff_summary
(
self
,
other
,
n_apply_to_print
=
15
,
n_ops_to_print
=
20
):
...
...
@@ -173,42 +158,23 @@ class ProfileMode(Mode):
r
[
a
]
+=
t
return
r
def
diff_dict_flops
(
a_time
,
b_time_
,
a_call
,
b_call
):
flops
=
{}
b_time
=
copy
.
copy
(
b_time_
)
for
a
,
ta
in
a_time
.
items
():
tb
=
b_time
.
pop
(
a
,
0
)
if
hasattr
(
a
,
'flops'
):
flops
[
a
]
=
a
.
flops
*
a_call
[
a
]
/
ta
-
a
.
flops
*
b_call
[
a
]
/
tb
/
1e6
#they are missing in a
for
b
,
tb
in
b_time
.
items
():
if
hasattr
(
b
,
'flops'
):
flops
[
b
]
=
b
.
flops
*
b_call
[
b
]
/
tb
/
1e6
return
flops
local_time
=
self
.
local_time
[
0
]
-
other
.
local_time
[
0
]
compile_time
=
self
.
compile_time
-
other
.
compile_time
fct_call_time
=
diff_dict
(
self
.
fct_call_time
,
other
.
fct_call_time
)
fct_call
=
diff_dict
(
self
.
fct_call
,
other
.
fct_call
)
apply_time
=
diff_dict
(
self
.
apply_time
,
other
.
apply_time
)
apply_call
=
diff_dict
(
self
.
apply_call
,
other
.
apply_call
)
op_time
=
diff_dict
(
self
.
op_time
,
other
.
op_time
)
op_call
=
diff_dict
(
self
.
op_call
,
other
.
op_call
)
op_cimpl
=
self
.
op_cimpl
and
other
.
op_cimpl
op_flops
=
diff_dict_flops
(
self
.
op_time
,
other
.
op_time
,
self
.
op_call
,
other
.
op_call
)
self
.
print_summary_
(
"print_diff_summary"
,
local_time
,
compile_time
,
fct_call_time
,
fct_call
,
apply_time
,
apply_call
,
op_
time
,
op_call
,
op_
cimpl
,
op_flops
,
n_apply_to_print
=
n_apply_to_print
,
apply_time
,
apply_call
,
op_cimpl
,
n_apply_to_print
=
n_apply_to_print
,
n_ops_to_print
=
n_ops_to_print
,
print_apply
=
False
)
@staticmethod
def
print_summary_
(
fct_name
,
local_time
,
compile_time
,
fct_call_time
,
fct_call
,
apply_time
,
apply_call
,
op_
time
,
op_call
,
op_
cimpl
,
op_flops
=
None
,
n_apply_to_print
=
15
,
n_ops_to_print
=
20
,
print_apply
=
True
):
apply_time
,
apply_call
,
op_cimpl
,
n_apply_to_print
=
15
,
n_ops_to_print
=
20
,
print_apply
=
True
):
"""
do the actual printing of print_summary and print_diff_summary.
...
...
@@ -238,6 +204,19 @@ class ProfileMode(Mode):
sum
(
f
for
f
,
t
,
a
,
nb_call
in
atimes
[
n_apply_to_print
:])
*
100
,
sum
(
t
for
f
,
t
,
a
,
nb_call
in
atimes
[
n_apply_to_print
:]))
op_time
=
{}
op_call
=
{}
for
(
i
,
a
),
t
in
apply_time
.
items
():
op_time
.
setdefault
(
a
,
0
)
op_call
.
setdefault
(
a
,
0
)
op_time
[
a
]
+=
t
op_call
[
a
]
+=
apply_call
[(
i
,
a
)]
op_flops
=
{}
for
a
,
t
in
op_time
.
items
():
if
hasattr
(
a
,
'flops'
):
op_flops
[
a
]
=
a
.
flops
*
op_call
[
a
]
/
t
/
1e6
flops_msg
=
''
if
op_flops
:
flops_msg
=
' <MFlops/s>'
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论