Skip to content

Commit

Permalink
【PIR API adaptor No.3】 Migrate paddle.acosh into pir (PaddlePaddle#58450
Browse files Browse the repository at this point in the history
)
  • Loading branch information
MarioLulab authored and zeroRains committed Nov 8, 2023
1 parent 51d8733 commit eac7fc8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion python/paddle/tensor/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def acosh(x, name=None):
Tensor(shape=[4], dtype=float32, place=Place(cpu), stop_gradient=True,
[0. , 1.76274717, 2.06343699, 2.29243159])
"""
if in_dynamic_mode():
if in_dynamic_or_pir_mode():
return _C_ops.acosh(x)
else:
check_variable_and_dtype(
Expand Down
13 changes: 9 additions & 4 deletions test/legacy_test/test_activation_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -2191,14 +2191,19 @@ 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
if self.dtype == np.complex64:
# Complex64[CPU]: AssertionError: 0.012431525 not less than or equal to 0.005
self.check_grad(['X'], 'Out', max_relative_error=0.02)
self.check_grad(
['X'], 'Out', max_relative_error=0.02, check_pir=True
)
else:
self.check_grad(['X'], 'Out')
self.check_grad(['X'], 'Out', check_pir=True)


class TestAcosh_Complex64(TestAcosh):
Expand Down Expand Up @@ -4724,7 +4729,7 @@ def test_check_grad(self):
create_test_act_fp16_class(TestSinh)
create_test_act_fp16_class(TestAsin)
create_test_act_fp16_class(TestAtan)
create_test_act_fp16_class(TestAcosh)
create_test_act_fp16_class(TestAcosh, check_pir=True)
create_test_act_fp16_class(TestAsinh)
create_test_act_fp16_class(TestAtanh)
create_test_act_fp16_class(TestRound, grad_check=False, check_pir=True)
Expand Down Expand Up @@ -4878,7 +4883,7 @@ def test_check_grad(self):
create_test_act_bf16_class(TestSinh)
create_test_act_bf16_class(TestAsin)
create_test_act_bf16_class(TestAtan)
create_test_act_bf16_class(TestAcosh)
create_test_act_bf16_class(TestAcosh, check_pir=True)
create_test_act_bf16_class(TestAsinh)
create_test_act_bf16_class(TestAtanh)
create_test_act_bf16_class(TestRound, grad_check=False, check_pir=True)
Expand Down

0 comments on commit eac7fc8

Please sign in to comment.