提交 3eefb097 编写于 作者: P phlrain

update; test=develop

上级 c1c6b869
...@@ -24,6 +24,7 @@ paddle.enable_static() ...@@ -24,6 +24,7 @@ paddle.enable_static()
class TestBitwiseAnd(OpTest): class TestBitwiseAnd(OpTest):
def setUp(self): def setUp(self):
self.op_type = "bitwise_and" self.op_type = "bitwise_and"
self.python_api = paddle.bitwise_and
self.init_dtype() self.init_dtype()
self.init_shape() self.init_shape()
self.init_bound() self.init_bound()
...@@ -94,6 +95,7 @@ class TestBitwiseAndInt64(TestBitwiseAnd): ...@@ -94,6 +95,7 @@ class TestBitwiseAndInt64(TestBitwiseAnd):
class TestBitwiseAndBool(TestBitwiseAnd): class TestBitwiseAndBool(TestBitwiseAnd):
def setUp(self): def setUp(self):
self.op_type = "bitwise_and" self.op_type = "bitwise_and"
self.python_api = paddle.bitwise_and
self.init_shape() self.init_shape()
x = np.random.choice([True, False], self.x_shape) x = np.random.choice([True, False], self.x_shape)
...@@ -108,6 +110,7 @@ class TestBitwiseAndBool(TestBitwiseAnd): ...@@ -108,6 +110,7 @@ class TestBitwiseAndBool(TestBitwiseAnd):
class TestBitwiseOr(OpTest): class TestBitwiseOr(OpTest):
def setUp(self): def setUp(self):
self.op_type = "bitwise_or" self.op_type = "bitwise_or"
self.python_api = paddle.bitwise_or
self.init_dtype() self.init_dtype()
self.init_shape() self.init_shape()
self.init_bound() self.init_bound()
...@@ -178,6 +181,7 @@ class TestBitwiseOrInt64(TestBitwiseOr): ...@@ -178,6 +181,7 @@ class TestBitwiseOrInt64(TestBitwiseOr):
class TestBitwiseOrBool(TestBitwiseOr): class TestBitwiseOrBool(TestBitwiseOr):
def setUp(self): def setUp(self):
self.op_type = "bitwise_or" self.op_type = "bitwise_or"
self.python_api = paddle.bitwise_or
self.init_shape() self.init_shape()
x = np.random.choice([True, False], self.x_shape) x = np.random.choice([True, False], self.x_shape)
...@@ -192,6 +196,7 @@ class TestBitwiseOrBool(TestBitwiseOr): ...@@ -192,6 +196,7 @@ class TestBitwiseOrBool(TestBitwiseOr):
class TestBitwiseXor(OpTest): class TestBitwiseXor(OpTest):
def setUp(self): def setUp(self):
self.op_type = "bitwise_xor" self.op_type = "bitwise_xor"
self.python_api = paddle.bitwise_xor
self.init_dtype() self.init_dtype()
self.init_shape() self.init_shape()
self.init_bound() self.init_bound()
...@@ -262,6 +267,7 @@ class TestBitwiseXorInt64(TestBitwiseXor): ...@@ -262,6 +267,7 @@ class TestBitwiseXorInt64(TestBitwiseXor):
class TestBitwiseXorBool(TestBitwiseXor): class TestBitwiseXorBool(TestBitwiseXor):
def setUp(self): def setUp(self):
self.op_type = "bitwise_xor" self.op_type = "bitwise_xor"
self.python_api = paddle.bitwise_xor
self.init_shape() self.init_shape()
x = np.random.choice([True, False], self.x_shape) x = np.random.choice([True, False], self.x_shape)
......
...@@ -503,6 +503,9 @@ def bitwise_and(x, y, out=None, name=None): ...@@ -503,6 +503,9 @@ def bitwise_and(x, y, out=None, name=None):
res = paddle.bitwise_and(x, y) res = paddle.bitwise_and(x, y)
print(res) # [0, 2, 1] print(res) # [0, 2, 1]
""" """
if _in_eager_mode() and out == None:
return _C_ops.final_state_bitwise_and(x, y)
return _bitwise_op( return _bitwise_op(
op_name="bitwise_and", x=x, y=y, name=name, out=out, binary_op=True) op_name="bitwise_and", x=x, y=y, name=name, out=out, binary_op=True)
...@@ -529,6 +532,9 @@ def bitwise_or(x, y, out=None, name=None): ...@@ -529,6 +532,9 @@ def bitwise_or(x, y, out=None, name=None):
res = paddle.bitwise_or(x, y) res = paddle.bitwise_or(x, y)
print(res) # [-1, -1, -3] print(res) # [-1, -1, -3]
""" """
if _in_eager_mode() and out == None:
return _C_ops.final_state_bitwise_or(x, y)
return _bitwise_op( return _bitwise_op(
op_name="bitwise_or", x=x, y=y, name=name, out=out, binary_op=True) op_name="bitwise_or", x=x, y=y, name=name, out=out, binary_op=True)
...@@ -555,6 +561,9 @@ def bitwise_xor(x, y, out=None, name=None): ...@@ -555,6 +561,9 @@ def bitwise_xor(x, y, out=None, name=None):
res = paddle.bitwise_xor(x, y) res = paddle.bitwise_xor(x, y)
print(res) # [-1, -3, -4] print(res) # [-1, -3, -4]
""" """
if _in_eager_mode() and out == None:
return _C_ops.final_state_bitwise_xor(x, y)
return _bitwise_op( return _bitwise_op(
op_name="bitwise_xor", x=x, y=y, name=name, out=out, binary_op=True) op_name="bitwise_xor", x=x, y=y, name=name, out=out, binary_op=True)
...@@ -580,7 +589,7 @@ def bitwise_not(x, out=None, name=None): ...@@ -580,7 +589,7 @@ def bitwise_not(x, out=None, name=None):
print(res) # [4, 0, -2] print(res) # [4, 0, -2]
""" """
if _in_eager_mode() and out == None: if _in_eager_mode() and out == None:
return _C_op.final_state_bitwise_not(x) return _C_ops.final_state_bitwise_not(x)
return _bitwise_op( return _bitwise_op(
op_name="bitwise_not", x=x, y=None, name=name, out=out, binary_op=False) op_name="bitwise_not", x=x, y=None, name=name, out=out, binary_op=False)
......
...@@ -538,32 +538,32 @@ ...@@ -538,32 +538,32 @@
# bitwise_and # bitwise_and
# - api : bitwise_and - api : bitwise_and
# args : (Tensor x, Tensor y) args : (Tensor x, Tensor y)
# output : Tensor output : Tensor
# infer_meta : infer_meta :
# func : BitwiseInferMeta func : ElementwiseInferMeta
# kernel : kernel :
# func : bitwise_and func : bitwise_and
# # bitwise_or # bitwise_or
# - api : bitwise_or - api : bitwise_or
# args : (Tensor x, Tensor y) args : (Tensor x, Tensor y)
# output : Tensor output : Tensor
# infer_meta : infer_meta :
# func : BitwiseInferMeta func : ElementwiseInferMeta
# kernel : kernel :
# func : bitwise_or func : bitwise_or
# # bitwise_xor # bitwise_xor
# - api : bitwise_xor - api : bitwise_xor
# args : (Tensor x, Tensor y) args : (Tensor x, Tensor y)
# output : Tensor output : Tensor
# infer_meta : infer_meta :
# func : BitwiseInferMeta func : ElementwiseInferMeta
# kernel : kernel :
# func : bitwise_xor func : bitwise_xor
# bitwise_not # bitwise_not
- api : bitwise_not - api : bitwise_not
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册