提交 130e6464 authored 作者: Lijun Xue's avatar Lijun Xue

Fix list remove value error

上级 f479a4f8
...@@ -948,8 +948,9 @@ class ProfileStats(object): ...@@ -948,8 +948,9 @@ class ProfileStats(object):
mem_freed += var_mem[ins] mem_freed += var_mem[ins]
elif ins in view_of: elif ins in view_of:
origin = view_of[ins] origin = view_of[ins]
viewed_by[origin].remove(ins) if ins in viewed_by[origin]:
viewedby_remove[origin].append(ins) viewed_by[origin].remove(ins)
viewedby_remove[origin].append(ins)
if (not viewed_by[origin] and if (not viewed_by[origin] and
origin not in fgraph.inputs and origin not in fgraph.inputs and
not isinstance(origin, theano.Constant)): not isinstance(origin, theano.Constant)):
......
...@@ -965,9 +965,9 @@ class VM_Linker(link.LocalLinker): ...@@ -965,9 +965,9 @@ class VM_Linker(link.LocalLinker):
for ins in node.inputs: for ins in node.inputs:
assert not (ins in view_of and viewed_by[ins]) assert not (ins in view_of and viewed_by[ins])
if (getattr(ins, 'ndim', None) == 0 and not storage_map[ins][0] if (getattr(ins, 'ndim', None) == 0 and not storage_map[ins][0]
and ins not in fgraph.outputs and ins.owner and ins not in fgraph.outputs and ins.owner
and all([compute_map_re[v][0] for v in dependencies.get(ins, [])])): and all([compute_map_re[v][0] for v in dependencies.get(ins, [])])):
# Constant Memory cannot be changed, Constant storage_map # Constant Memory cannot be changed, Constant storage_map
# has a value here # has a value here
reuse_out = None reuse_out = None
...@@ -982,7 +982,8 @@ class VM_Linker(link.LocalLinker): ...@@ -982,7 +982,8 @@ class VM_Linker(link.LocalLinker):
pre_allocated.add(out) pre_allocated.add(out)
elif ins in view_of: elif ins in view_of:
origin = view_of[ins] origin = view_of[ins]
viewed_by[origin].remove(ins) if ins in viewed_by[origin]:
viewed_by[origin].remove(ins)
if (not viewed_by[origin] and if (not viewed_by[origin] and
origin not in fgraph.inputs and origin not in fgraph.inputs and
not isinstance(origin, theano.Constant)): not isinstance(origin, theano.Constant)):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论