Bug#855102: theano: SamplingDot broken on negative-stride arrays

Rebecca N. Palmer rebecca_palmer at zoho.com
Tue Feb 14 07:48:48 UTC 2017


Package: theano
Version: 0.8.2-3
Severity: important
Control: tags -1 upstream

Because Numpy arrays' data pointer is the first element in *index* order 
but BLAS expects the first element in *memory* order, simply calling a 
BLAS function as in SamplingDotCSR 
(https://sources.debian.net/src/theano/0.8.2-4/theano/sparse/opt.py/#L1902) 
doesn't work on negative-stride arrays:

import theano
import theano.sparse
import theano.tensor
import numpy as np
import scipy.sparse
x=[theano.tensor.matrix(),theano.tensor.matrix(),theano.sparse.csr_matrix()]
f=theano.function(x,theano.sparse.sampling_dot(*x))
m1=np.random.rand(3,5)
m2=np.random.rand(8,5)
m3=m2[::-1,::-1]#negative strides
p=scipy.sparse.csr_matrix(np.zeros((3,8)))
p[1,2]=1
print(f(m1,m2,p)[1,2],np.dot(m1,m2.T)[1,2])#equal
print(f(m1,m3,p)[1,2],np.dot(m1,m3.T)[1,2],f(m1,np.array(m3),p)[1,2])#should 
be equal, but aren't

I expect to post a fix tonight (mostly a copy from UsmmCscDense, plus 
c_code_cache_version bump).



More information about the debian-science-maintainers mailing list