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] NO.33 Migrate paddle.equal into pir #57678

Merged
merged 3 commits into from
Sep 26, 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
8 changes: 4 additions & 4 deletions python/paddle/tensor/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,16 +533,16 @@ def equal(x, y, name=None):
Tensor(shape=[3], dtype=bool, place=Place(cpu), stop_gradient=True,
[True , False, False])
"""
if not isinstance(y, (int, bool, float, Variable)):
if not isinstance(y, (int, bool, float, Variable, paddle.pir.OpResult)):
raise TypeError(
"Type of input args must be float, bool, int or Tensor, but received type {}".format(
type(y)
)
)
if not isinstance(y, Variable):
if not isinstance(y, (Variable, paddle.pir.OpResult)):
y = full(shape=[], dtype=x.dtype, fill_value=y)

if in_dynamic_mode():
if in_dynamic_or_pir_mode():
return _C_ops.equal(x, y)
else:
check_variable_and_dtype(
Expand Down Expand Up @@ -598,7 +598,7 @@ def equal_(x, y, name=None):
out_shape, x.shape
)
)
if in_dynamic_mode():
if in_dynamic_or_pir_mode():
return _C_ops.equal_(x, y)


Expand Down
4 changes: 2 additions & 2 deletions test/legacy_test/test_compare_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def test_errors(self):
create_test_class(
'greater_equal', _type_name, lambda _a, _b: _a >= _b, True
)
create_test_class('equal', _type_name, lambda _a, _b: _a == _b)
create_test_class('equal', _type_name, lambda _a, _b: _a == _b, True)
create_test_class('not_equal', _type_name, lambda _a, _b: _a != _b)


Expand Down Expand Up @@ -473,7 +473,7 @@ def test_check_output(self):
create_bf16_case('less_equal', lambda _a, _b: _a <= _b)
create_bf16_case('greater_than', lambda _a, _b: _a > _b)
create_bf16_case('greater_equal', lambda _a, _b: _a >= _b, True)
create_bf16_case('equal', lambda _a, _b: _a == _b)
create_bf16_case('equal', lambda _a, _b: _a == _b, True)
create_bf16_case('not_equal', lambda _a, _b: _a != _b)


Expand Down