提交 27406aae authored 作者: Roy Xue's avatar Roy Xue

Add sublists stores the index to node_clear_order

Remains a question for the Hack coarse gc final pass. when run this the apply_stack is empty, we can’t find the index of node v
上级 4d7725f7
......@@ -414,6 +414,10 @@ class Stack(VM):
self.thunks[self.node_idx[current_apply]])
for o in current_apply.outputs:
compute_map[o][0] = 1
input_index = []
# A list store the index of inputs variables
if self.allow_gc:
for i in current_apply.inputs:
# Garbage Collection -> check if anybody else uses
......@@ -424,7 +428,7 @@ class Stack(VM):
if all(compute_map[v][0]
for v in dependencies[i]):
storage_map[i][0] = None
self.node_cleared_order.append(storage_map[i])
input_index.append(current_apply.inputs.index(i))
#DO NOT set compute_map to 0
......@@ -447,6 +451,8 @@ class Stack(VM):
#The stack level is not good when inside a Scan.
stacklevel=3
)
self.node_cleared_order.append(input_index)
elif not computed_ins:
# -- Non-lazy case, need inputs
apply_stack.append(current_apply)
......@@ -454,6 +460,7 @@ class Stack(VM):
for inp in current_deps
if inp.owner)
elif not computed_outs:
#
# stack loop: Lazy Evaluation Case
......@@ -500,6 +507,8 @@ class Stack(VM):
st = 'c'
self.variable_strides[var] = st
input_index = []
if self.allow_gc:
for i in current_apply.inputs:
if (dependencies[i] and i.owner and
......@@ -511,19 +520,25 @@ class Stack(VM):
break
if empty_storage_map:
storage_map[i][0] = None
self.node_cleared_order.append(storage_map[i])
input_index.append(current_apply.inputs.index(i))
#See the not lazy gc code for explanations
#of compute_map change
compute_map[i][0] = 2
self.node_cleared_order.append(input_index)
# Hacky coarse gc final pass
# This is required until we have a proper gc algorithm for graphs with
# lazy evaluation. See discussion on theano-dev June 19 2012.
final_index = []
if self.allow_gc:
for v in storage_map:
if v.owner and not v in self.outputs:
storage_map[v][0] = None
self.node_cleared_order.append(storage_map[v])
final_index.append(v)
self.node_cleared_order.append(final_index)
try:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论