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] Migrate paddle.sin into pir #58094

Merged
merged 3 commits into from
Oct 17, 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
2 changes: 1 addition & 1 deletion python/paddle/tensor/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ def sin(x, name=None):
Tensor(shape=[4], dtype=float32, place=Place(cpu), stop_gradient=True,
[-0.38941833, -0.19866933, 0.09983342, 0.29552022])
"""
if in_dynamic_mode():
if in_dynamic_or_pir_mode():
return _C_ops.sin(x)
else:
check_variable_and_dtype(
Expand Down
17 changes: 13 additions & 4 deletions test/legacy_test/test_activation_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from paddle import base, static
from paddle.base import Program, core, program_guard
from paddle.base.layer_helper import LayerHelper
from paddle.pir_utils import test_with_pir_api


@contextmanager
Expand Down Expand Up @@ -2062,14 +2063,22 @@ def setUp(self):
def init_shape(self):
self.shape = [10, 12]

@test_with_pir_api
def test_out_name(self):
# inherit from `TestParameter`
super().test_out_name()

def test_check_output(self):
self.check_output(check_pir=True)

def test_check_grad(self):
if self.dtype == np.float16:
return
# TODO(ScottWong98): set `check_prim=False` when `fill_any_like` supports `complex` dtype
if self.dtype == np.complex64 or self.dtype == np.complex128:
self.check_grad(['X'], 'Out', check_prim=False)
self.check_grad(['X'], 'Out', check_prim=False, check_pir=True)
else:
self.check_grad(['X'], 'Out', check_prim=True)
self.check_grad(['X'], 'Out', check_prim=True, check_pir=True)

def if_enable_cinn(self):
pass
Expand Down Expand Up @@ -4664,7 +4673,7 @@ def test_check_grad(self):
create_test_act_fp16_class(TestTan)
create_test_act_fp16_class(TestCosh)
create_test_act_fp16_class(TestAcos)
create_test_act_fp16_class(TestSin)
create_test_act_fp16_class(TestSin, check_pir=True)
create_test_act_fp16_class(TestSinh)
create_test_act_fp16_class(TestAsin)
create_test_act_fp16_class(TestAtan)
Expand Down Expand Up @@ -4814,7 +4823,7 @@ def test_check_grad(self):
create_test_act_bf16_class(TestTan)
create_test_act_bf16_class(TestCosh)
create_test_act_bf16_class(TestAcos)
create_test_act_bf16_class(TestSin)
create_test_act_bf16_class(TestSin, check_pir=True)
create_test_act_bf16_class(TestSinh)
create_test_act_bf16_class(TestAsin)
create_test_act_bf16_class(TestAtan)
Expand Down