提交 810415ed authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Update sparse test to test more combinations.

上级 55cd62b2
......@@ -347,24 +347,24 @@ class test_structureddot(unittest.TestCase):
def test_dot_sparse_sparse(self):
#test dot for 2 input sparse matrix
sparse_dtype = 'float64'
for sparse_format in ['csc','csr']:
a = SparseType(sparse_format, dtype=sparse_dtype)()
b = SparseType(sparse_format, dtype=sparse_dtype)()
d = theano.dot(a,b)
f = theano.function([a,b], theano.Out(d, borrow=True))
topo = f.maker.env.toposort()
for M,N,K,nnz in [(4,3,2,3),
(40,30,20,3),
(40,30,20,30),
(400,3000,200,6000),
]:
if sparse_format == 'csc':
spmat = sp.csc_matrix(random_lil((M,N), sparse_dtype, nnz))
spmat2 = sp.csc_matrix(random_lil((N,K), sparse_dtype, nnz))
elif sparse_format == 'csr':
spmat = sp.csr_matrix(random_lil((M,N), sparse_dtype, nnz))
spmat2 = sp.csr_matrix(random_lil((N,K), sparse_dtype, nnz))
f(spmat,spmat2)
sp_mat = {'csc':sp.csc_matrix,
'csr':sp.csr_matrix}
for sparse_format_a in ['csc','csr']:
for sparse_format_b in ['csc', 'csr']:
a = SparseType(sparse_format_a, dtype=sparse_dtype)()
b = SparseType(sparse_format_b, dtype=sparse_dtype)()
d = theano.dot(a,b)
f = theano.function([a,b], theano.Out(d, borrow=True))
topo = f.maker.env.toposort()
for M,N,K,nnz in [(4,3,2,3),
(40,30,20,3),
(40,30,20,30),
(400,3000,200,6000),
]:
a_val = sp_mat[sparse_format_a](random_lil((M,N), sparse_dtype, nnz))
b_val = sp_mat[sparse_format_b](random_lil((N,K), sparse_dtype, nnz))
f(a_val, b_val)
def test_csc_correct_output_faster_than_scipy(self):
sparse_dtype = 'float64'
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论