Unverified Commit d55e21ff by pankratz Committed by GitHub

Fixed bug in ExprOp that caused bitwise operators to fail when a basic python…

Fixed bug in ExprOp that caused bitwise operators to fail when a basic python type was on the left hand side of the expression. Added regression test for crashing cases. (#4852)
parent ee2d3cc3
......@@ -113,12 +113,21 @@ class ExprOp(object):
def __and__(self, other):
return _make.bitwise_and(self, other)
def __rand__(self, other):
return _make.bitwise_and(other, self)
def __or__(self, other):
return _make.bitwise_or(self, other)
def __ror__(self, other):
return _make.bitwise_or(other, self)
def __xor__(self, other):
return _make.bitwise_xor(self, other)
def __rxor__(self, other):
return _make.bitwise_xor(other, self)
def __invert__(self):
return _make.Call(self.dtype, "bitwise_not", [self], Call.PureIntrinsic, None, 0)
......
......@@ -175,6 +175,9 @@ def test_bitwise():
assert str(x & y) == 'bitwise_and(x, y)'
assert str(x | y) == 'bitwise_or(x, y)'
assert str(x ^ y) == 'bitwise_xor(x, y)'
assert str(10 & x) == 'bitwise_and(10, x)'
assert str(10 | x) == 'bitwise_or(10, x)'
assert str(10 ^ x) == 'bitwise_xor(10, x)'
assert str(~x) == 'bitwise_not(x)'
assert(tvm.const(1, "int8x2") >> 1).dtype == "int8x2"
assert(x >> tvm.const(1, "int32x2")).dtype == "int32x2"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment