Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
cfd4b870
提交
cfd4b870
authored
3月 09, 2013
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make the memory profiler print the shape.
上级
6e6d00ba
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
30 行增加
和
26 行删除
+30
-26
profiling.py
theano/compile/profiling.py
+24
-8
vm.py
theano/gof/vm.py
+6
-18
没有找到文件。
theano/compile/profiling.py
浏览文件 @
cfd4b870
...
...
@@ -145,6 +145,9 @@ class ProfileStats(object):
optimizer_profile
=
None
# None or tuple (the optimizer, the profile it returned)
memory_size_map
=
{
"nt8"
:
1
,
"t16"
:
2
,
"t32"
:
4
,
"t64"
:
8
,
"128"
:
16
}
# param is called flag_time_thunks because most other attributes with time
# in the name are times *of* something, rather than configuration flags.
def
__init__
(
self
,
atexit_print
=
True
,
flag_time_thunks
=
None
,
**
kwargs
):
...
...
@@ -557,14 +560,26 @@ class ProfileStats(object):
def
summary_memory
(
self
,
file
,
N
=
None
):
fct_memory
=
{}
# fgraph->dict(node->(outputs size))
fct_shapes
=
{}
# fgraph->dict(node->[outputs shapes]))
var_mem
=
{}
for
node
,
val
in
self
.
outputs_size
.
items
():
for
node
,
shapes
in
self
.
outputs_size
.
items
():
fct_memory
.
setdefault
(
node
.
fgraph
,
{})
fct_memory
[
node
.
fgraph
][
node
]
=
val
for
out
,
v
in
zip
(
node
.
outputs
,
val
):
fct_memory
[
node
.
fgraph
]
.
setdefault
(
node
,
[])
fct_shapes
.
setdefault
(
node
.
fgraph
,
{})
fct_shapes
[
node
.
fgraph
]
.
setdefault
(
node
,
[])
for
out
,
sh
in
zip
(
node
.
outputs
,
shapes
):
v
=
numpy
.
prod
(
sh
)
dtype
=
str
(
out
.
dtype
)
v
*=
self
.
memory_size_map
[
dtype
[
-
3
:]]
var_mem
[
out
]
=
v
fct_memory
[
node
.
fgraph
][
node
]
.
append
(
v
)
fct_shapes
[
node
.
fgraph
][
node
]
.
append
(
sh
)
assert
len
(
fct_memory
)
==
1
print
print
"
Profile of Theano functions memory:
"
print
"
Memory Profile
"
for
fgraph
,
nodes_mem
in
fct_memory
.
iteritems
():
size_sum
=
sum
([
sum
(
val
)
...
...
@@ -622,7 +637,7 @@ class ProfileStats(object):
node_memory_size
-
running_max_memory_size
)
/
1024
print
print
" <Sum apply outputs (bytes)> <Apply outputs
memory size(bytes)
> <created/inplace/view> <Apply node>"
print
" <Sum apply outputs (bytes)> <Apply outputs
shape
> <created/inplace/view> <Apply node>"
print
" <created/inplace/view> is taked from the op declaration."
print
" Use DebugMode for warnings about inplace/view declaration being respected."
print
...
...
@@ -632,10 +647,11 @@ class ProfileStats(object):
code
[
out
]
=
"i"
for
out
,
inp
in
getattr
(
key
.
op
,
'view_map'
,
{})
.
iteritems
():
code
[
out
]
=
"v"
print
'
%9
dB
%
s
%
s
%
s'
%
(
sum
(
val
),
str
(
val
),
' '
.
join
(
code
),
key
)
shapes
=
str
(
fct_shapes
[
fgraph
][
key
])
print
'
%9
dB
%
s
%
s
%
s'
%
(
sum
(
val
),
shapes
,
' '
.
join
(
code
),
key
)
sum_remaining
=
sum
(
sum
(
val
)
for
key
,
val
in
items
[
N
:])
sum_remaining
=
sum
(
sum
(
shapes
)
for
key
,
shapes
in
items
[
N
:])
print
(
' ... (remaining
%
i Apply account for
%.2
f
%%
(
%.2
fs) of'
' the runtime)'
)
%
(
max
(
0
,
len
(
nodes_mem
)
-
N
),
sum_remaining
,
...
...
theano/gof/vm.py
浏览文件 @
cfd4b870
...
...
@@ -365,16 +365,10 @@ class Stack(VM):
for
(
idx
,
o
)
in
enumerate
(
thunks
[
self
.
node_idx
[
current_apply
]]
.
outputs
):
if
not
hasattr
(
o
[
0
],
's
iz
e'
):
size
.
append
(
-
1
)
if
not
hasattr
(
o
[
0
],
's
hap
e'
):
size
.
append
(
'no shape'
)
continue
s
=
o
[
0
]
.
size
dtype
=
str
(
o
[
0
]
.
dtype
)
dtype2
=
dtype
[
-
3
:]
# KeyError here: couldn't determine
# the dtype memory size
s
*=
self
.
memory_size_map
[
dtype2
]
size
.
append
(
s
)
size
.
append
(
o
[
0
]
.
shape
)
self
.
outputs_size
[
current_apply
]
=
size
except
Exception
:
raise_with_op
(
current_apply
)
...
...
@@ -448,16 +442,10 @@ class Stack(VM):
size
=
[]
for
(
idx
,
o
)
in
enumerate
(
thunks
[
self
.
node_idx
[
current_apply
]]
.
outputs
):
if
not
hasattr
(
o
[
0
],
's
iz
e'
):
size
.
append
(
-
1
)
if
not
hasattr
(
o
[
0
],
's
hap
e'
):
size
.
append
(
'no shape'
)
continue
s
=
o
[
0
]
.
size
dtype
=
str
(
o
[
0
]
.
dtype
)
dtype2
=
dtype
[
-
2
:]
# KeyError here: couldn't determine the
# dtype memory size
s
*=
self
.
memory_size_map
[
dtype2
]
size
.
append
(
s
)
size
.
append
(
o
[
0
]
.
shape
)
self
.
outputs_size
[
current_apply
]
=
size
if
self
.
allow_gc
:
for
i
in
current_apply
.
inputs
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论