提交 f784c7b5 authored 作者: James Bergstra's avatar James Bergstra

added explicit c cast to scalar.Cast.c_code... this should eliminate compiler warnings

上级 69674ee1
......@@ -219,6 +219,7 @@ class Scalar(Type):
+ operator_eq % dict(mytype='theano_complex64')
def c_code_cache_version(self):
#return ()
return (3,) #explicit T given in specialization of operator= lines. This makes it compile with open64
#2,
......@@ -855,12 +856,22 @@ class Cast(UnaryScalarOp):
def impl(self, input):
return self.ctor(input)
def c_code(self, node, name, (x, ), (z, ), sub):
return "%(z)s = %(x)s;" % locals()
#HACK: we assume that x has the form 'VARNAME_i',
# and we need the varname to get the dtype.
assert (len(x) > 2) and (x[-2:] == '_i')
varname = x[:-2]
return "%s = (dtype_%s)%s;" % (z, varname, x)
def grad(self, (x, ), (gz, )):
if x.type in grad_types:
return [cast(gz, x.type.dtype)]
else:
return None,
def c_code_cache_version(self):
s = super(Cast, self).c_code_cache_version()
if s:
return (2,) + s
else:
return s
convert_to_int8 = Cast(int8, name='convert_to_int8')
convert_to_int16 = Cast(int16, name='convert_to_int16')
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论