diff --git a/python/paddle/fluid/tests/unittests/test_bitwise_op.py b/python/paddle/fluid/tests/unittests/test_bitwise_op.py index 67070602c2c0061e85e1adc9b6afb98d1b3cf6d8..4f01d31fb1cb651c8017700e22b1d932d6c9b6fb 100644 --- a/python/paddle/fluid/tests/unittests/test_bitwise_op.py +++ b/python/paddle/fluid/tests/unittests/test_bitwise_op.py @@ -24,6 +24,7 @@ paddle.enable_static() class TestBitwiseAnd(OpTest): def setUp(self): self.op_type = "bitwise_and" + self.python_api = paddle.bitwise_and self.init_dtype() self.init_shape() self.init_bound() @@ -94,6 +95,7 @@ class TestBitwiseAndInt64(TestBitwiseAnd): class TestBitwiseAndBool(TestBitwiseAnd): def setUp(self): self.op_type = "bitwise_and" + self.python_api = paddle.bitwise_and self.init_shape() x = np.random.choice([True, False], self.x_shape) @@ -108,6 +110,7 @@ class TestBitwiseAndBool(TestBitwiseAnd): class TestBitwiseOr(OpTest): def setUp(self): self.op_type = "bitwise_or" + self.python_api = paddle.bitwise_or self.init_dtype() self.init_shape() self.init_bound() @@ -178,6 +181,7 @@ class TestBitwiseOrInt64(TestBitwiseOr): class TestBitwiseOrBool(TestBitwiseOr): def setUp(self): self.op_type = "bitwise_or" + self.python_api = paddle.bitwise_or self.init_shape() x = np.random.choice([True, False], self.x_shape) @@ -192,6 +196,7 @@ class TestBitwiseOrBool(TestBitwiseOr): class TestBitwiseXor(OpTest): def setUp(self): self.op_type = "bitwise_xor" + self.python_api = paddle.bitwise_xor self.init_dtype() self.init_shape() self.init_bound() @@ -262,6 +267,7 @@ class TestBitwiseXorInt64(TestBitwiseXor): class TestBitwiseXorBool(TestBitwiseXor): def setUp(self): self.op_type = "bitwise_xor" + self.python_api = paddle.bitwise_xor self.init_shape() x = np.random.choice([True, False], self.x_shape) diff --git a/python/paddle/tensor/logic.py b/python/paddle/tensor/logic.py index a07c1d9c103064f3bda4d4cbc3dbcdc6ff3fd0cf..545f0e9bd5f9d99c5918558ea571e6a5d9e6190c 100755 --- a/python/paddle/tensor/logic.py +++ b/python/paddle/tensor/logic.py @@ -503,6 +503,9 @@ def bitwise_and(x, y, out=None, name=None): res = paddle.bitwise_and(x, y) print(res) # [0, 2, 1] """ + if _in_eager_mode() and out == None: + return _C_ops.final_state_bitwise_and(x, y) + return _bitwise_op( 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): res = paddle.bitwise_or(x, y) print(res) # [-1, -1, -3] """ + if _in_eager_mode() and out == None: + return _C_ops.final_state_bitwise_or(x, y) + return _bitwise_op( 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): res = paddle.bitwise_xor(x, y) print(res) # [-1, -3, -4] """ + if _in_eager_mode() and out == None: + return _C_ops.final_state_bitwise_xor(x, y) + return _bitwise_op( 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): print(res) # [4, 0, -2] """ 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( op_name="bitwise_not", x=x, y=None, name=name, out=out, binary_op=False) diff --git a/python/paddle/utils/code_gen/api.yaml b/python/paddle/utils/code_gen/api.yaml index 6479025e71ca74267647837e56392d9df9acfc33..998a9425d4121b4871246417e0578f13e55c54af 100644 --- a/python/paddle/utils/code_gen/api.yaml +++ b/python/paddle/utils/code_gen/api.yaml @@ -538,32 +538,32 @@ # bitwise_and -# - api : bitwise_and -# args : (Tensor x, Tensor y) -# output : Tensor -# infer_meta : -# func : BitwiseInferMeta -# kernel : -# func : bitwise_and +- api : bitwise_and + args : (Tensor x, Tensor y) + output : Tensor + infer_meta : + func : ElementwiseInferMeta + kernel : + func : bitwise_and -# # bitwise_or -# - api : bitwise_or -# args : (Tensor x, Tensor y) -# output : Tensor -# infer_meta : -# func : BitwiseInferMeta -# kernel : -# func : bitwise_or +# bitwise_or +- api : bitwise_or + args : (Tensor x, Tensor y) + output : Tensor + infer_meta : + func : ElementwiseInferMeta + kernel : + func : bitwise_or -# # bitwise_xor -# - api : bitwise_xor -# args : (Tensor x, Tensor y) -# output : Tensor -# infer_meta : -# func : BitwiseInferMeta -# kernel : -# func : bitwise_xor +# bitwise_xor +- api : bitwise_xor + args : (Tensor x, Tensor y) + output : Tensor + infer_meta : + func : ElementwiseInferMeta + kernel : + func : bitwise_xor # bitwise_not - api : bitwise_not