提交 c2a526cc authored 作者: Olivier Delalleau's avatar Olivier Delalleau

Cosmetic changes

上级 f0f84950
...@@ -531,28 +531,28 @@ class Function(object): ...@@ -531,28 +531,28 @@ class Function(object):
for k, arg in kwargs.iteritems(): for k, arg in kwargs.iteritems():
self[k] = arg self[k] = arg
## Collect aliased inptus among the storage space ## Collect aliased inputs among the storage space
args_share_memory = [] args_share_memory = []
for i in xrange(len(self.input_storage)): for i in xrange(len(self.input_storage)):
if self.input_storage[i].storage[0] != None: if self.input_storage[i].storage[0] is not None:
is_aliased = False is_aliased = False
for j in xrange(len(args_share_memory)): for j in xrange(len(args_share_memory)):
if numpy.may_share_memory( if numpy.may_share_memory(
self.input_storage[i].storage[0] , self.input_storage[i].storage[0] ,
self.input_storage[args_share_memory[j][0]].storage[0]): self.input_storage[args_share_memory[j][0]].storage[0]):
is_aliased = True is_aliased = True
args_share_memory[j] += [i] args_share_memory[j].append(i)
break break
if not is_aliased: if not is_aliased:
args_share_memory.append( [i] ) args_share_memory.append([i])
# Check for groups of more than one argument that share memory # Check for groups of more than one argument that share memory
for group in args_share_memory: for group in args_share_memory:
if len(group) > 1: if len(group) > 1:
# see if any of these arguments are mutable # see if any of these arguments are mutable
mutable = numpy.any( [self.maker.inputs[idx].mutable for mutable = numpy.any([self.maker.inputs[idx].mutable
idx in group]) for idx in group])
# copy all but the first # copy all but the first
for idx in group[1:]: for idx in group[1:]:
self.input_storage[i].storage[0] = copy.copy( self.input_storage[i].storage[0] = copy.copy(
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论