提交 f7dacab5 authored 作者: Frederic's avatar Frederic

Fix a test error related type typenum of ulonglong and uint64 being different…

Fix a test error related type typenum of ulonglong and uint64 being different even if they are equivalent.
上级 d59aaf11
...@@ -2677,6 +2677,27 @@ class TrueDot(gof.op.Op): ...@@ -2677,6 +2677,27 @@ class TrueDot(gof.op.Op):
rval = x.dot(y) rval = x.dot(y)
if not scipy.sparse.issparse(rval): if not scipy.sparse.issparse(rval):
rval = getattr(scipy.sparse, x.format + '_matrix')(rval) rval = getattr(scipy.sparse, x.format + '_matrix')(rval)
#x.dot call tocsr() that will "upcast" to ['int8', 'uint8', 'short',
# 'ushort', 'intc', 'uintc', 'longlong', 'ulonglong', 'single',
# 'double', 'longdouble', 'csingle', 'cdouble', 'clongdouble']
# But ulonglong is uint64 on x86-64, but with a different typenum!
if rval.dtype.num != numpy.dtype(str(rval.dtype)).num:
assert str(rval.dtype) == node.outputs[0].dtype
# Create a view with the expected typenum.
format = node.outputs[0].type.format
data = rval.data.view(dtype=node.outputs[0].dtype)
indices = rval.indices
indptr = rval.indptr
shape = rval.shape
# No need to copy indices and indptr as in CSM.perform(),
# as there is only one user of them.
if format == 'csc':
rval = scipy.sparse.csc_matrix((data, indices, indptr),
shape, copy=False)
else:
assert format == 'csr'
rval = scipy.sparse.csr_matrix((data, indices, indptr),
shape, copy=False)
out[0] = rval out[0] = rval
def grad(self, (x, y), (gz, )): def grad(self, (x, y), (gz, )):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论