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

Fixed C compilation crash under Windows 32 bit, where setting a theano_complex64…

Fixed C compilation crash under Windows 32 bit, where setting a theano_complex64 to 0 was not supported
上级 afaf6ce8
...@@ -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
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论