提交 d4563178 authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Fix memory leak in scan related to the input and output storage of the inner function.

上级 a7b9a7e8
......@@ -1104,6 +1104,13 @@ class Scan(PureOp):
# little trick that I used
outs[idx][0] = outs[idx][0][:-(n_steps - i)]
# Make sure to release storage if allow_gc is True
if getattr(fn, 'allow_gc', False):
for i in input_storage:
i.storage[0] = None
for o in output_storage:
o.storage[0] = None
t_call = time.time() - t0_call
# NOTE: make this match what's in function_module.Function
# and this little string helps us to find this spot:
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -62,7 +62,7 @@ import copy
def get_version():
return 0.281
return 0.282
@cython.boundscheck(False)
def perform(
......@@ -456,6 +456,13 @@ def perform(
sh0 = outs[idx][0].shape[0]
outs[idx][0] = outs[idx][0][:sh0-(n_steps - i)]
# Make sure to release storage if allow_gc is True
if getattr(fn, 'allow_gc', False):
for i in input_storage:
i.storage[0] = None
for o in output_storage:
o.storage[0] = None
t_call = time.time() - t0_call
if hasattr(fnct.maker, 'profile'):
......
......@@ -16,7 +16,7 @@ _logger = logging.getLogger('theano.scan_module.scan_perform')
_logger.setLevel(logging.WARN)
version = 0.281 # must match constant returned in function get_version()
version = 0.282 # must match constant returned in function get_version()
need_reload = False
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论