提交 5acbca53 authored 作者: James Bergstra's avatar James Bergstra

fixed bug in function to prevent accidentally zeroing results which are both an output and input

上级 2c290d27
...@@ -288,8 +288,12 @@ class Function(object): ...@@ -288,8 +288,12 @@ class Function(object):
# if we are allowing garbage collection, remove the input and output reference from the internal # if we are allowing garbage collection, remove the input and output reference from the internal
# storage cells # storage cells
if getattr(self.fn, 'allow_gc', False): if getattr(self.fn, 'allow_gc', False):
for x in self.output_storage: assert len(self.output_storage) == len(self.maker.env.outputs)
x.storage[0] = None #WARNING: This circumvents the 'readonly' attribute in x for o_container, o_result in zip(self.output_storage, self.maker.env.outputs):
if o_result.owner is not None:
# this node is the result of computation
# WARNING: This circumvents the 'readonly' attribute in x
o_container.storage[0] = None
# Update the inputs that have an update function # Update the inputs that have an update function
for input, storage in reversed(zip(self.maker.expanded_inputs, self.input_storage)): for input, storage in reversed(zip(self.maker.expanded_inputs, self.input_storage)):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论