提交 26f8db44 authored 作者: Frederic Bastien's avatar Frederic Bastien

simplified code following code review.

上级 e1bec46e
...@@ -829,20 +829,7 @@ class Invert(UnaryBitOp): ...@@ -829,20 +829,7 @@ class Invert(UnaryBitOp):
def impl(self, x): def impl(self, x):
return ~x return ~x
def c_code(self, node, name, (x,), (z, ), sub): def c_code(self, node, name, (x,), (z, ), sub):
dtype = node.inputs[0].type.dtype return "%(z)s = (~%(x)s);" % locals()
# For an unknow reason, the pattern must have 2 times the number of bits
# then the inputs...
if dtype == 'int8':
pattern = "0xFF"
elif dtype == 'int16':
pattern = "0xFFFF"
elif dtype == 'int32':
pattern = "0xFFFFFFFF"
elif dtype == 'int64':
pattern = "0xFFFFFFFFFFFFFFFF"
else:
super(Invert, self).c_code(node, name, (x,), (z, ), sub)
return "%(z)s = (%(x)s ^ %(pattern)s);" % locals()
invert = Invert() invert = Invert()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论