Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
6879fb89
提交
6879fb89
authored
7月 25, 2014
作者:
Roy Xue
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
updates
上级
fdb93264
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
5 行增加
和
65 行删除
+5
-65
profiling.py
theano/compile/profiling.py
+3
-63
test_profiling.py
theano/compile/tests/test_profiling.py
+2
-2
没有找到文件。
theano/compile/profiling.py
浏览文件 @
6879fb89
...
@@ -637,7 +637,6 @@ class ProfileStats(object):
...
@@ -637,7 +637,6 @@ class ProfileStats(object):
new_max_node_memory_saved_by_view
=
0
new_max_node_memory_saved_by_view
=
0
new_max_node_memory_saved_by_inplace
=
0
new_max_node_memory_saved_by_inplace
=
0
def
count_running_memory
(
order
,
thunk_old_storage
,
nodes_mem
):
def
count_running_memory
(
order
,
thunk_old_storage
,
nodes_mem
):
"""
"""
Calculate memory with specific node order
Calculate memory with specific node order
...
@@ -696,19 +695,13 @@ class ProfileStats(object):
...
@@ -696,19 +695,13 @@ class ProfileStats(object):
def
count_minimum_peak
(
node_list
,
fgraph
,
nodes_mem
):
def
count_minimum_peak
(
node_list
,
fgraph
,
nodes_mem
):
global
maybe_executed
global
maybe_executed
mem_list
=
[]
order_index
=
0
order
=
[]
order
=
[]
min_order
=
[]
node_list
=
list
(
node_list
)
node_list
=
list
(
node_list
)
min_mem
=
sys
.
maxint
min_mem
=
sys
.
maxint
current_mem
=
0
current_mem
=
0
check_len
=
len
(
node_list
)
check_len
=
len
(
node_list
)
compute_map
=
defaultdict
(
lambda
:
[
0
])
# compute_map use to check if a node is valid
for
node
in
fgraph
.
inputs
:
compute_map
[
node
][
0
]
=
1
def
check_node_state
(
node
):
def
check_node_state
(
node
):
"""
"""
check if an Apply node is valid(has inputs but no outputs).
check if an Apply node is valid(has inputs but no outputs).
...
@@ -730,49 +723,10 @@ class ProfileStats(object):
...
@@ -730,49 +723,10 @@ class ProfileStats(object):
else
:
else
:
return
False
return
False
# maybe_executed = set()
compute_map
=
defaultdict
(
lambda
:
[
0
])
# for var in fgraph.inputs:
# compute_map use to check if a node is valid
# for c, _ in var.clients:
# maybe_executed.add(c)
# current = 0
# def min_memory_generator(node_list):
# '''
# enumerate all valid orders for the list of nodes in node_list
# compute the peak of all order and keep the order with the minimum peak.
# return minimum memory usage
# :param node_list: a list of apply nodes
# :param compute_map: simulate the node execution steps to update compute_map
# '''
# global maybe_executed, current
# for i in range(len(node_list)):
# v = node_list[i:i+1]
# if v[0] in maybe_executed:
# if check_node_state(v[0]):
# maybe_executed.remove(v[0])
# for node in v[0].outputs:
# compute_map[node][0] = 1
# for c, _ in node.clients:
# if c != "output":
# maybe_executed.add(c)
# if len(node_list) == 1:
# yield v
# else:
# rest = node_list[ :i] + node_list[i+1: ]
# for p in min_memory_generator(rest):
# yield v+p
# for node in v[0].outputs:
# compute_map[node][0] = 0
# maybe_executed.add(v[0])
executables_nodes
=
set
()
executables_nodes
=
set
()
# compute_map use to check if a node is valid
for
var
in
fgraph
.
inputs
:
for
var
in
fgraph
.
inputs
:
compute_map
[
var
][
0
]
=
1
compute_map
[
var
][
0
]
=
1
for
var
in
fgraph
.
inputs
:
for
var
in
fgraph
.
inputs
:
...
@@ -780,9 +734,6 @@ class ProfileStats(object):
...
@@ -780,9 +734,6 @@ class ProfileStats(object):
if
c
!=
"output"
and
check_node_state
(
c
):
if
c
!=
"output"
and
check_node_state
(
c
):
executables_nodes
.
add
(
c
)
executables_nodes
.
add
(
c
)
def
min_memory_generator
(
executables_nodes
):
def
min_memory_generator
(
executables_nodes
):
for
node
in
executables_nodes
:
for
node
in
executables_nodes
:
new_exec_nodes
=
executables_nodes
.
copy
()
new_exec_nodes
=
executables_nodes
.
copy
()
...
@@ -801,12 +752,6 @@ class ProfileStats(object):
...
@@ -801,12 +752,6 @@ class ProfileStats(object):
for
var
in
node
.
outputs
:
for
var
in
node
.
outputs
:
compute_map
[
var
][
0
]
=
0
compute_map
[
var
][
0
]
=
0
min_order
=
[]
# for count memory
# I tested 2 way
# 1. create a new simple method
# 2. using sum(nodes_mem[v[0]])
def
count_min_memory
(
order
,
thunk_old_storage
,
nodes_mem
):
def
count_min_memory
(
order
,
thunk_old_storage
,
nodes_mem
):
running_memory_size
=
0
running_memory_size
=
0
running_max_memory_size
=
0
running_max_memory_size
=
0
...
@@ -832,12 +777,7 @@ class ProfileStats(object):
...
@@ -832,12 +777,7 @@ class ProfileStats(object):
return
running_max_memory_size
return
running_max_memory_size
i
=
0
for
order
in
min_memory_generator
(
executables_nodes
):
for
order
in
min_memory_generator
(
executables_nodes
):
# print i
i
+=
1
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
:
...
...
theano/compile/tests/test_profiling.py
浏览文件 @
6879fb89
...
@@ -42,8 +42,8 @@ def test_profiling():
...
@@ -42,8 +42,8 @@ def test_profiling():
# regression testing for future algo speed up
# regression testing for future algo speed up
the_string
=
buf
.
getvalue
()
the_string
=
buf
.
getvalue
()
assert
"Max if linker=cvm(default): 82
24KB (16408
KB)"
in
the_string
assert
"Max if linker=cvm(default): 82
08KB (16400
KB)"
in
the_string
assert
"Minimum peak from all valid apply node order is 8
208
KB"
in
the_string
assert
"Minimum peak from all valid apply node order is 8
192
KB"
in
the_string
finally
:
finally
:
theano
.
config
.
profile
=
old1
theano
.
config
.
profile
=
old1
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论