提交 6fb77ff0 authored 作者: Frederic's avatar Frederic

Comments

上级 9966c2fa
...@@ -624,6 +624,12 @@ def gc_helper(node_list): ...@@ -624,6 +624,12 @@ def gc_helper(node_list):
dictionary that maps each Variable instance to a the last node to use Variable as an input. dictionary that maps each Variable instance to a the last node to use Variable as an input.
This is used to allow garbage collection within graphs. This is used to allow garbage collection within graphs.
It ignore view_map and destroy_map. This isn't needed as python
have referecence count. In Theano gc, we should not take into
account view_map and destroy_map as if the thunk decided to create
a new output, we would delay uselessly its gc by Python.
""" """
# for freeing memory # for freeing memory
last_user = {} last_user = {}
......
...@@ -378,8 +378,8 @@ class Stack(VM): ...@@ -378,8 +378,8 @@ class Stack(VM):
# destroy_dependencies # destroy_dependencies
# -------------------- # --------------------
# The destroy_dependencies is a list of variables that are implicit # The destroy_dependencies is a list of variables that are implicit
# dependencies induced by a destroy_map (compare node.inputs which # dependencies induced by destroy_map and view_map (compared to
# are *explicit* dependencies). The variables in # node.inputs which are *explicit* dependencies). The variables in
# destroy_dependencies would be impossible to compute after the # destroy_dependencies would be impossible to compute after the
# current `node` runs, because node.thunk() is going to destroy a # current `node` runs, because node.thunk() is going to destroy a
# common input variable needed by whatever node owns each variable # common input variable needed by whatever node owns each variable
...@@ -787,6 +787,12 @@ class VM_Linker(link.LocalLinker): ...@@ -787,6 +787,12 @@ class VM_Linker(link.LocalLinker):
N.B. gc means garbage collection N.B. gc means garbage collection
Note
----
It don't take care of the view_map/destroy_map. So
it mean it rely on Python gc to don't free the object real
storage.
""" """
dependencies = {} dependencies = {}
for k in variables: for k in variables:
...@@ -796,6 +802,9 @@ class VM_Linker(link.LocalLinker): ...@@ -796,6 +802,9 @@ class VM_Linker(link.LocalLinker):
# way of getting it back. # way of getting it back.
# #
# XXX if k has no clients... what is it doing in the computation? # XXX if k has no clients... what is it doing in the computation?
# Fred guess: it could happen for node with multiple outputs when
# we don't use all outputs.
if k.owner and k.clients: if k.owner and k.clients:
ls = [] ls = []
for cl in k.clients: for cl in k.clients:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论