Skip to content
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 @@ -1147,7 +1147,7 @@ def tan(x, name=None):
Tensor(shape=[4], dtype=float32, place=Place(cpu), stop_gradient=True,
[-0.42279324, -0.20271003, 0.10033467, 0.30933627])
"""
if in_dynamic_mode():
if in_dynamic_or_pir_mode():
return _C_ops.tan(x)
else:
check_variable_and_dtype(
Expand Down
10 changes: 7 additions & 3 deletions test/legacy_test/test_activation_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -1957,10 +1957,13 @@ def setUp(self):
def init_shape(self):
self.shape = [10, 12]

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

def test_check_grad(self):
if self.dtype == np.float16:
return
self.check_grad(['X'], 'Out')
self.check_grad(['X'], 'Out', check_pir=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TestTan 继承自 TestActivation. TestActivation 有一个 test_check_output 需要继承重写并打开 check_pir 开关。麻烦添加一下吧~

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.



class TestTan_float32(TestTan):
Expand Down Expand Up @@ -2001,6 +2004,7 @@ def test_dygraph_api(self):
out_ref = np.tan(self.x_np)
np.testing.assert_allclose(out_ref, out_test.numpy(), rtol=1e-05)

@test_with_pir_api
def test_static_api(self):
with static_guard():
with paddle.static.program_guard(paddle.static.Program()):
Expand Down Expand Up @@ -4745,7 +4749,7 @@ def test_check_grad(self):
check_pir=True,
)
create_test_act_fp16_class(TestCos, check_pir=True)
create_test_act_fp16_class(TestTan)
create_test_act_fp16_class(TestTan, check_pir=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

类似于 create_test_act_fp16_class, 在该文件内还有一个 create_test_act_bf16_class(TestTan) 创建了 bf16 的单测,麻烦也打开一下吧~

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

create_test_act_fp16_class(TestCosh)
create_test_act_fp16_class(TestAcos, check_pir=True)
create_test_act_fp16_class(TestSin, check_pir=True)
Expand Down Expand Up @@ -4899,7 +4903,7 @@ def test_check_grad(self):
TestFloor, grad_check=False, check_prim=True, check_pir=True
)
create_test_act_bf16_class(TestCos, check_pir=True)
create_test_act_bf16_class(TestTan)
create_test_act_bf16_class(TestTan, check_pir=True)
create_test_act_bf16_class(TestCosh)
create_test_act_bf16_class(TestAcos, check_pir=True)
create_test_act_bf16_class(TestSin, check_pir=True)
Expand Down