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