diff --git a/python/paddle/tensor/ops.py b/python/paddle/tensor/ops.py index 6df64f8b9b9d81..b73a1bc154066f 100644 --- a/python/paddle/tensor/ops.py +++ b/python/paddle/tensor/ops.py @@ -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( diff --git a/test/legacy_test/test_activation_op.py b/test/legacy_test/test_activation_op.py index 5621b6a1947cb4..82d976a3f952bc 100644 --- a/test/legacy_test/test_activation_op.py +++ b/test/legacy_test/test_activation_op.py @@ -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 @@ -2066,14 +2067,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 @@ -4675,7 +4684,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) @@ -4827,7 +4836,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)