提交 7a0b002f authored 作者: Olivier Breuleux's avatar Olivier Breuleux

fixed Abs.c_code to use fabs on float input

上级 c64b127c
......@@ -324,7 +324,8 @@ class Abs(UnaryScalarOp):
def grad(self, (x, ), (gz, )):
return gz * sgn(x),
def c_code(self, (x, ), (z, ), sub):
return "%(z)s = abs(%(x)s);" % locals()
return "%(z)s = %(prefix)sabs(%(x)s);" \
% dict(locals(), prefix = 'float' in self.inputs[0].dtype and 'f' or '')
class Sgn(UnaryScalarOp):
def impl(self, x):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论