提交 f3b720ea authored 作者: Roy Xue's avatar Roy Xue

DONe_SET Algo

上级 637dd104
......@@ -798,6 +798,8 @@ class ProfileStats(object):
# This take only the inputs/outputs dependencies.
dependencies = fgraph.profile.dependencies
DONE_SET = set([])
list_set = []
list_mem = []
# Initial compute_map which is used to check if a node is valid
compute_map = defaultdict(lambda: [0])
......@@ -910,6 +912,37 @@ class ProfileStats(object):
mem_count -= mem_freed
DONE_SET.add(node)
if DONE_SET not in list_set:
set_copy = DONE_SET.copy()
list_set.append(set_copy)
list_mem.append(mem_count)
else:
set_idx = list_set.index(DONE_SET)
past_mem = list_mem[set_idx]
if past_mem > mem_count:
list_mem[set_idx] = mem_count
else:
DONE_SET.remove(node)
mem_count -= mem_created
max_mem_count = max_storage
mem_count += mem_freed
for var in node.outputs:
compute_map[var][0] = 0
for k_remove, v_remove in viewedby_remove.iteritems():
for i in v_remove:
viewed_by[k_remove].append(i)
for k_add, v_add in viewedby_add.iteritems():
for i in v_add:
viewed_by[k_add].remove(i)
for k in viewof_change:
del view_of[k]
continue
for var in node.outputs:
for c, _ in var.clients:
if c != "output":
......@@ -925,6 +958,7 @@ class ProfileStats(object):
min_memory_generator(new_exec_nodes, viewed_by, view_of)
# Reset track variables
DONE_SET.remove(node)
mem_count -= mem_created
max_mem_count = max_storage
mem_count += mem_freed
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论