提交 fdbf70cf authored 作者: Olivier Delalleau's avatar Olivier Delalleau

Merged -- no conflict

...@@ -256,6 +256,13 @@ class Scalar(Type): ...@@ -256,6 +256,13 @@ class Scalar(Type):
if self.dtype.startswith('complex'): if self.dtype.startswith('complex'):
cplx_types = ['theano_complex64', 'theano_complex128'] cplx_types = ['theano_complex64', 'theano_complex128']
real_types = ['npy_int8', 'npy_int16', 'npy_int32', 'npy_int64', 'npy_float32', 'npy_float64'] real_types = ['npy_int8', 'npy_int16', 'npy_int32', 'npy_int64', 'npy_float32', 'npy_float64']
# If the 'int' C type is not exactly the same as an existing
# 'npy_intX', some C code may not compile, e.g. when assigning
# the value 0 (cast to 'int' in C) to a theano_complex64.
if (numpy.dtype('intc').num not in
[numpy.dtype(d[4:]).num for d in real_types]):
# In that case we add the 'int' type to the real types.
real_types.append('int')
template = """ template = """
struct theano_complex%(nbits)s : public npy_complex%(nbits)s struct theano_complex%(nbits)s : public npy_complex%(nbits)s
...@@ -383,6 +390,7 @@ class Scalar(Type): ...@@ -383,6 +390,7 @@ class Scalar(Type):
return "" return ""
def c_code_cache_version(self): def c_code_cache_version(self):
return (11, numpy.__version__) # Ensure the 'int' C type is among the real types
return (10, numpy.__version__) # Use the correct type checking and conversion functions return (10, numpy.__version__) # Use the correct type checking and conversion functions
return (9, numpy.__version__) # Make operators work with 64 and 128 arguments at the same time return (9, numpy.__version__) # Make operators work with 64 and 128 arguments at the same time
return (8, numpy.__version__) # put const around operators and added unary '-' operator return (8, numpy.__version__) # put const around operators and added unary '-' operator
......
...@@ -262,7 +262,11 @@ class EnsureSortedIndices(Op): ...@@ -262,7 +262,11 @@ class EnsureSortedIndices(Op):
return gof.Apply(self, [x], [x.type()]) return gof.Apply(self, [x], [x.type()])
def perform(self,node, (x,), (z,)): def perform(self,node, (x,), (z,)):
z[0] = x.ensure_sorted_indices(inplace=self.inplace) if self.inplace:
x.sort_indices()
z[0] = x
else:
z[0] = x.sorted_indices()
def grad(self, (x,), (gz,)): def grad(self, (x,), (gz,)):
return [gz] return [gz]
...@@ -408,11 +412,12 @@ class ConvolutionIndices(Op): ...@@ -408,11 +412,12 @@ class ConvolutionIndices(Op):
l+=1 # move on to next filter tap l=(l+1)%ksize l+=1 # move on to next filter tap l=(l+1)%ksize
if spmat.format != 'csc': if spmat.format != 'csc':
spmat = spmat.tocsc().ensure_sorted_indices() spmat = spmat.tocsc().sorted_indices()
else: else:
# BUG ALERT: scipy0.6 has bug where data and indices are written in reverse column # BUG ALERT: scipy0.6 has bug where data and indices are written in
# ordering. Explicit call to ensure_sorted_indices removes this problem # reverse column ordering.
spmat = spmat.ensure_sorted_indices() # Explicit call to sorted_indices removes this problem.
spmat = spmat.sorted_indices()
if ws: if ws:
kmap = None kmap = None
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论