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]Add rsqrt to new ir & op_test passed (4/4) #57325

Merged
merged 6 commits into from
Sep 15, 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
4 changes: 2 additions & 2 deletions python/paddle/tensor/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from .. import _C_ops
from ..base.data_feeder import check_variable_and_dtype
from ..framework import LayerHelper, in_dynamic_mode
from ..framework import LayerHelper, in_dynamic_mode, in_dynamic_or_pir_mode
from .layer_function_generator import (
add_sample_code,
generate_activation_fn,
Expand Down Expand Up @@ -878,7 +878,7 @@ def rsqrt(x, name=None):
Tensor(shape=[4], dtype=float32, place=Place(cpu), stop_gradient=True,
[3.16227770, 2.23606801, 1.82574177, 1.58113885])
"""
if in_dynamic_mode():
if in_dynamic_or_pir_mode():
return _C_ops.rsqrt(x)
else:
check_variable_and_dtype(
Expand Down
9 changes: 6 additions & 3 deletions test/legacy_test/test_activation_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -1578,7 +1578,7 @@ def if_enable_cinn(self):
pass

def test_check_output(self):
self.check_output(check_prim=True)
self.check_output(check_prim=True, check_new_ir=True)

def test_check_grad(self):
if self.dtype == np.float16:
Expand All @@ -1588,6 +1588,7 @@ def test_check_grad(self):
'Out',
max_relative_error=0.0005,
check_prim=True,
check_new_ir=True,
)


Expand Down Expand Up @@ -4507,7 +4508,9 @@ def test_check_grad(self):
TestLeakyReluAlpha3, check_prim=True, enable_cinn=True
)
create_test_act_fp16_class(TestLeakyRelu_ZeroDim, check_prim=True)
create_test_act_fp16_class(TestRsqrt, check_prim=True, enable_cinn=True)
create_test_act_fp16_class(
TestRsqrt, check_prim=True, enable_cinn=True, check_new_ir=True
)


def create_test_act_bf16_class(
Expand Down Expand Up @@ -4629,7 +4632,7 @@ def test_check_grad(self):
create_test_act_bf16_class(TestLeakyReluAlpha2, check_prim=True)
create_test_act_bf16_class(TestLeakyReluAlpha3, check_prim=True)
create_test_act_bf16_class(TestLeakyRelu_ZeroDim, check_prim=True)
create_test_act_bf16_class(TestRsqrt, check_prim=True)
create_test_act_bf16_class(TestRsqrt, check_prim=True, check_new_ir=True)

if __name__ == "__main__":
unittest.main()