提交 fb607620 authored 作者: ChienliMa's avatar ChienliMa

Minor fixes of typos and reverse modiication of test_reallocation()

上级 5aa12370
...@@ -551,7 +551,7 @@ class Function(object): ...@@ -551,7 +551,7 @@ class Function(object):
there.data = here.data there.data = here.data
return cpy return cpy
def copy(self, share_memory = False): def copy(self, share_memory=False):
""" """
Copy this function. Copied function will have separated maker and fgraph Copy this function. Copied function will have separated maker and fgraph
with original function. User can choose whether to separate storage by with original function. User can choose whether to separate storage by
...@@ -593,7 +593,8 @@ class Function(object): ...@@ -593,7 +593,8 @@ class Function(object):
# But to be safe for now as it isn't documented and we aren't sure # But to be safe for now as it isn't documented and we aren't sure
# it is well tested, we don't share the part of the storage_map. # it is well tested, we don't share the part of the storage_map.
for key in storage_map.keys(): for key in storage_map.keys():
if key not in self.maker.fgraph.outputs: if key not in self.maker.fgraph.outputs and \
not isinstance(key, theano.tensor.Constant):
new_storage_map[memo[key]] = storage_map[key] new_storage_map[memo[key]] = storage_map[key]
# copy input storages if it's mutable # copy input storages if it's mutable
...@@ -606,13 +607,10 @@ class Function(object): ...@@ -606,13 +607,10 @@ class Function(object):
else: else:
input_storage.append( copy.deepcopy[storage]) input_storage.append( copy.deepcopy[storage])
<<<<<<< HEAD
new_func = new_maker.create(input_storage, storage_map=new_storage_map) new_func = new_maker.create(input_storage, storage_map=new_storage_map)
return new_func return new_func
=======
>>>>>>> 87f2056... Delete extra line
def __call__(self, *args, **kwargs): def __call__(self, *args, **kwargs):
profile = self.profile profile = self.profile
t0 = time.time() t0 = time.time()
......
...@@ -368,9 +368,6 @@ def test_vm_gc(): ...@@ -368,9 +368,6 @@ def test_vm_gc():
def test_reallocation(): def test_reallocation():
"""
test share memory.
"""
x = tensor.scalar('x') x = tensor.scalar('x')
y = tensor.scalar('y') y = tensor.scalar('y')
z = tensor.tanh(3 * x + y) + tensor.cosh(x + 5 * y) z = tensor.tanh(3 * x + y) + tensor.cosh(x + 5 * y)
...@@ -387,10 +384,6 @@ def test_reallocation(): ...@@ -387,10 +384,6 @@ def test_reallocation():
storage_map = f.fn.storage_map storage_map = f.fn.storage_map
def check_storage(storage_map): def check_storage(storage_map):
"""
Return [True, same_value] if two storages have same value,
otherwise return [False, None]
"""
from theano.tensor.var import TensorConstant from theano.tensor.var import TensorConstant
for i in storage_map: for i in storage_map:
if not isinstance(i, TensorConstant): if not isinstance(i, TensorConstant):
...@@ -402,7 +395,6 @@ def test_reallocation(): ...@@ -402,7 +395,6 @@ def test_reallocation():
return [True, storage_map[o][0]] return [True, storage_map[o][0]]
return [False, None] return [False, None]
# assert there's same value in strage_map
assert check_storage(storage_map)[0] assert check_storage(storage_map)[0]
assert len(set(id(v) for v in assert len(set(id(v) for v in
itervalues(storage_map))) < len(storage_map) itervalues(storage_map))) < len(storage_map)
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论