提交 98127db0 authored 作者: ChienliMa's avatar ChienliMa

change of variable name and some some docs in test_reallocation()

上级 c00ccdd5
...@@ -368,6 +368,9 @@ def test_vm_gc(): ...@@ -368,6 +368,9 @@ 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)
...@@ -384,6 +387,10 @@ def test_reallocation(): ...@@ -384,6 +387,10 @@ 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):
...@@ -395,6 +402,7 @@ def test_reallocation(): ...@@ -395,6 +402,7 @@ 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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论