提交 83de4225 authored 作者: Frederic Bastien's avatar Frederic Bastien

disabled the c code of the mod operator as it don't give the same result at the…

disabled the c code of the mod operator as it don't give the same result at the py version when their is one or both of the signe with an operand.
上级 2df7a067
...@@ -517,7 +517,7 @@ class ScalarOp(Op): ...@@ -517,7 +517,7 @@ class ScalarOp(Op):
return "%s{%s}" % (self.__class__.__name__, ", ".join("%s=%s" % (k, v) for k, v in self.__dict__.items() if k != "name")) return "%s{%s}" % (self.__class__.__name__, ", ".join("%s=%s" % (k, v) for k, v in self.__dict__.items() if k != "name"))
def c_code_cache_version(self): def c_code_cache_version(self):
return (2,) return (3,)
class UnaryScalarOp(ScalarOp): class UnaryScalarOp(ScalarOp):
...@@ -842,10 +842,14 @@ int_div = IntDiv(upcast_out, name = 'int_div') ...@@ -842,10 +842,14 @@ int_div = IntDiv(upcast_out, name = 'int_div')
class Mod(BinaryScalarOp): class Mod(BinaryScalarOp):
def impl(self, x, y): def impl(self, x, y):
return x % y return x % y
def c_code_cache_version(self):
return (3,)
def c_code(self, node, name, (x, y), (z, ), sub): def c_code(self, node, name, (x, y), (z, ), sub):
""" """
We want the result to have the same sign as python, not the other implementaiton of mod. We want the result to have the same sign as python, not the other implementaiton of mod.
""" """
raise NotImplementedError()
#raise NotImplementedError("Unlike Python, C's modulo returns negative modulo on negative dividend (to implement)") #raise NotImplementedError("Unlike Python, C's modulo returns negative modulo on negative dividend (to implement)")
t = node.inputs[0].type.upcast(*[ i.type for i in node.inputs[1:]]) t = node.inputs[0].type.upcast(*[ i.type for i in node.inputs[1:]])
if t in int_types or t in ['uint8','int8','uint16','int16','uint32','int32','uint64','int64']: if t in int_types or t in ['uint8','int8','uint16','int16','uint32','int32','uint64','int64']:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论