提交 9be4f33d authored 作者: Philippe Hamel's avatar Philippe Hamel

added test for aliased function inputs (ticket #374)

上级 cf3a1fe0
...@@ -538,6 +538,27 @@ def test_may_share_memory(): ...@@ -538,6 +538,27 @@ def test_may_share_memory():
]: ]:
assert SparseType.may_share_memory(a_,b_)==rep assert SparseType.may_share_memory(a_,b_)==rep
def test_sparse_shared_memory():
# Note : There are no inplace ops on sparse matrix yet. If one is someday implemented, we could test it here.
a = random_lil((3,4), 'float32', 3).tocsr()
m1 = random_lil((4,4), 'float32', 3).tocsr()
m2 = random_lil((4,4), 'float32', 3).tocsr()
x = SparseType('csr', dtype='float32')()
y = SparseType('csr', dtype='float32')()
sdot = theano.sparse.structured_dot
z = sdot(x*3,m1) + sdot(y*2, m2)
f = theano.function([theano.In(x,mutable=True),theano.In(y,mutable = True)],z, mode='FAST_RUN')
def f_(x,y,m1=m1,m2=m2):
return numpy.dot(x*3,m1) + numpy.dot(y*2,m2)
assert SparseType.may_share_memory(a,a) #This is trivial
result = f(a,a)
result_ = f_(a,a)
assert (result_.todense() == result.todense()).all()
import theano.tensor.tests.test_sharedvar import theano.tensor.tests.test_sharedvar
test_shared_options=theano.tensor.tests.test_sharedvar.makeSharedTester( test_shared_options=theano.tensor.tests.test_sharedvar.makeSharedTester(
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论