Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
8e42f3f9
提交
8e42f3f9
authored
5月 21, 2014
作者:
Roy Xue
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1. extend node_cleard_order in another allow_gc loop in ../gof/vm.py
2. add count_running_memory method to take places of 2 loops in ../compile/profiling.py 3. add new_order's memory value in Store the max stats
上级
49966686
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
38 行增加
和
50 行删除
+38
-50
profiling.py
theano/compile/profiling.py
+37
-50
vm.py
theano/gof/vm.py
+1
-0
没有找到文件。
theano/compile/profiling.py
浏览文件 @
8e42f3f9
...
@@ -628,6 +628,33 @@ class ProfileStats(object):
...
@@ -628,6 +628,33 @@ class ProfileStats(object):
max_running_max_memory_size
=
0
max_running_max_memory_size
=
0
max_node_memory_saved_by_view
=
0
max_node_memory_saved_by_view
=
0
max_node_memory_saved_by_inplace
=
0
max_node_memory_saved_by_inplace
=
0
def
count_running_memory
(
order
,
old_storage
):
for
node
in
order
:
val
=
nodes_mem
[
node
]
dmap
=
getattr
(
node
.
op
,
'destroy_map'
,
None
)
vmap
=
getattr
(
node
.
op
,
'view_map'
,
None
)
for
idx
,
v
in
enumerate
(
val
):
# TODO check the op returned a view
if
dmap
and
idx
in
dmap
:
node_memory_saved_by_inplace
+=
v
# TODO check the op returned a view
elif
vmap
and
idx
in
vmap
:
node_memory_saved_by_view
+=
v
elif
not
isinstance
(
v
,
str
):
node_memory_size
+=
v
running_memory_size
+=
v
if
running_memory_size
>
running_max_memory_size
:
running_max_memory_size
=
running_memory_size
old_storage
=
post_thunk_old_storage
[
order
.
index
(
node
)]
for
old_s
in
old_storage
:
old_v
=
var_mem
[
node
.
inputs
[
old_s
]]
if
not
isinstance
(
old_v
,
str
):
running_memory_size
-=
old_v
return
node_memory_size
,
running_memory_size
,
running_max_memory_size
,
node_memory_saved_by_inplace
,
node_memory_saved_by_view
for
fgraph
,
nodes_mem
in
fct_memory
.
iteritems
():
for
fgraph
,
nodes_mem
in
fct_memory
.
iteritems
():
# Sum of the size of all variables in bytes
# Sum of the size of all variables in bytes
sum_size
=
sum
([
sum
([
v
for
v
in
val
if
not
isinstance
(
v
,
str
)])
sum_size
=
sum
([
sum
([
v
for
v
in
val
if
not
isinstance
(
v
,
str
)])
...
@@ -665,12 +692,6 @@ class ProfileStats(object):
...
@@ -665,12 +692,6 @@ class ProfileStats(object):
# after the execution of the corresponding node.
# after the execution of the corresponding node.
# It mean that after executing the node,
# It mean that after executing the node,
# the corresponding variable can be gc.
# the corresponding variable can be gc.
new_order
=
fgraph
.
profile
.
node_executed_order
# A list of new executed node order
new_storage
=
fgraph
.
profile
.
node_cleared_order
# A list of variables that get freed
post_thunk_old_storage
=
[]
post_thunk_old_storage
=
[]
computed
,
last_user
=
theano
.
gof
.
link
.
gc_helper
(
order
)
computed
,
last_user
=
theano
.
gof
.
link
.
gc_helper
(
order
)
for
node
in
order
:
for
node
in
order
:
...
@@ -680,58 +701,24 @@ class ProfileStats(object):
...
@@ -680,58 +701,24 @@ class ProfileStats(object):
if
(
input
in
computed
)
and
if
(
input
in
computed
)
and
(
input
not
in
fgraph
.
outputs
)
and
(
input
not
in
fgraph
.
outputs
)
and
node
==
last_user
[
input
]])
node
==
last_user
[
input
]])
for
node
in
order
:
node_memory_size
,
running_memory_size
,
running_max_memory_size
,
node_memory_saved_by_view
,
node_memory_saved_by_inplace
=
count_running_memory
(
order
,
post_thunk_old_storage
)
val
=
nodes_mem
[
node
]
dmap
=
getattr
(
node
.
op
,
'destroy_map'
,
None
)
vmap
=
getattr
(
node
.
op
,
'view_map'
,
None
)
for
idx
,
v
in
enumerate
(
val
):
new_order
=
fgraph
.
profile
.
node_executed_order
# TODO check the op returned a view
# A list of new executed node order
if
dmap
and
idx
in
dmap
:
new_storage
=
fgraph
.
profile
.
node_cleared_order
node_memory_saved_by_inplace
+=
v
# A list of variables that get freed
# TODO check the op returned a view
elif
vmap
and
idx
in
vmap
:
node_memory_saved_by_view
+=
v
elif
not
isinstance
(
v
,
str
):
node_memory_size
+=
v
running_memory_size
+=
v
if
running_memory_size
>
running_max_memory_size
:
running_max_memory_size
=
running_memory_size
old_storage
=
post_thunk_old_storage
[
order
.
index
(
node
)]
for
old_s
in
old_storage
:
old_v
=
var_mem
[
node
.
inputs
[
old_s
]]
if
not
isinstance
(
old_v
,
str
):
running_memory_size
-=
old_v
for
node
in
new_order
:
val
=
nodes_mem
[
node
]
dmap
=
getattr
(
node
.
op
,
'destroy_map'
,
None
)
vmap
=
getattr
(
node
.
op
,
'view_map'
,
None
)
for
idx
,
v
in
enumerate
(
val
):
new_node_memory_size
,
new_running_memory_size
,
new_running_max_memory_size
,
new_node_memory_saved_by_view
,
new_node_memory_saved_by_inplace
=
count_running_memory
(
new_order
,
new_storage
)
if
dmap
and
idx
in
dmap
:
new_node_memory_saved_by_inplace
+=
v
elif
vmap
and
idx
in
vmap
:
new_node_memory_saved_by_view
+=
v
elif
not
isinstance
(
v
,
str
):
new_node_memory_size
+=
v
new_running_memory_size
+=
v
if
new_running_memory_size
>
new_running_max_memory_size
:
new_running_max_memory_size
=
new_running_memory_size
for
new_s
in
new_storage
:
new_v
=
var_mem
[
node
.
inputs
[
new_s
]]
if
not
isinstance
(
new_v
,
str
):
new_running_memory_size
-=
new_v
# Store the max of some stats by any function in this profile.
# Store the max of some stats by any function in this profile.
max_sum_size
=
max
(
max_sum_size
,
sum_size
)
max_sum_size
=
max
(
max_sum_size
,
sum_size
)
max_node_memory_size
=
max
(
max_node_memory_size
,
node_memory_size
)
max_node_memory_size
=
max
(
max_node_memory_size
,
node_memory_size
,
new_node_memory_size
)
max_running_max_memory_size
=
max
(
max_running_max_memory_size
,
max_running_max_memory_size
=
max
(
max_running_max_memory_size
,
running_max_memory_size
)
running_max_memory_size
,
new_running_max_memory_size
)
max_node_memory_saved_by_view
=
max
(
max_node_memory_saved_by_view
,
max_node_memory_saved_by_view
=
max
(
max_node_memory_saved_by_view
,
node_memory_saved_by_view
)
node_memory_saved_by_view
,
new_node_memory_saved_by_view
)
max_node_memory_saved_by_inplace
=
max
(
max_node_memory_saved_by_inplace
=
max
(
max_node_memory_saved_by_inplace
,
node_memory_saved_by_inplace
)
max_node_memory_saved_by_inplace
,
node_memory_saved_by_inplace
,
new_node_memory_saved_by_inplace
)
del
fgraph
,
nodes_mem
,
post_thunk_old_storage
,
node
del
fgraph
,
nodes_mem
,
post_thunk_old_storage
,
node
...
...
theano/gof/vm.py
浏览文件 @
8e42f3f9
...
@@ -521,6 +521,7 @@ class Stack(VM):
...
@@ -521,6 +521,7 @@ class Stack(VM):
for
v
in
storage_map
:
for
v
in
storage_map
:
if
v
.
owner
and
not
v
in
self
.
outputs
:
if
v
.
owner
and
not
v
in
self
.
outputs
:
storage_map
[
v
][
0
]
=
None
storage_map
[
v
][
0
]
=
None
self
.
node_cleared_order
.
append
(
storage_map
[
v
])
try
:
try
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论