Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【PIR API adaptor No.133-135】Migrate paddle.logical_not/logical_or/logical_xor into pir #58781

Merged
merged 4 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions python/paddle/tensor/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def logical_or(x, y, out=None, name=None):
[[True , True ],
[True , False]])
"""
if in_dynamic_mode():
if in_dynamic_or_pir_mode():
return _C_ops.logical_or(x, y)
return _logical_op(
op_name="logical_or", x=x, y=y, name=name, out=out, binary_op=True
Expand Down Expand Up @@ -262,7 +262,7 @@ def logical_xor(x, y, out=None, name=None):
[[False, True ],
[True , False]])
"""
if in_dynamic_mode():
if in_dynamic_or_pir_mode():
return _C_ops.logical_xor(x, y)

return _logical_op(
Expand Down Expand Up @@ -322,7 +322,7 @@ def logical_not(x, out=None, name=None):
Tensor(shape=[4], dtype=bool, place=Place(cpu), stop_gradient=True,
[False, True , False, True ])
"""
if in_dynamic_mode():
if in_dynamic_or_pir_mode():
return _C_ops.logical_not(x)
return _logical_op(
op_name="logical_not", x=x, y=None, name=name, out=out, binary_op=False
Expand Down
12 changes: 6 additions & 6 deletions test/legacy_test/test_logical_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import paddle
from paddle.framework import in_dynamic_mode
from paddle.static import Executor, Program, program_guard
from paddle.pir_utils import test_with_pir_api

SUPPORTED_DTYPES = [
bool,
Expand Down Expand Up @@ -67,16 +67,15 @@
}


# @test_with_pir_api
def run_static(x_np, y_np, op_str, use_gpu=False, binary_op=True):
paddle.enable_static()
startup_program = Program()
main_program = Program()
startup_program = paddle.static.Program()
main_program = paddle.static.Program()
place = paddle.CPUPlace()
if use_gpu and paddle.is_compiled_with_cuda():
place = paddle.CUDAPlace(0)
exe = Executor(place)
with program_guard(main_program, startup_program):
exe = paddle.static.Executor(place)
with paddle.static.program_guard(main_program, startup_program):
x = paddle.static.data(name='x', shape=x_np.shape, dtype=x_np.dtype)
op = getattr(paddle, op_str)
feed_list = {'x': x_np}
Expand Down Expand Up @@ -135,6 +134,7 @@ def np_data_generator(np_shape, dtype, *args, **kwargs):
return np.random.normal(0, 1, np_shape).astype(dtype)


@test_with_pir_api
def test(unit_test, use_gpu=False, test_error=False):
for op_data in TEST_META_OP_DATA:
meta_data = dict(op_data)
Expand Down