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 API adaptor No.12、13】 Migrate paddle.asin, paddle.asinh into pir #58470

Merged
merged 5 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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 @@ -336,7 +336,7 @@ def asin(x, name=None):
Tensor(shape=[4], dtype=float32, place=Place(cpu), stop_gradient=True,
[-0.41151685, -0.20135793, 0.10016742, 0.30469266])
"""
if in_dynamic_mode():
if in_dynamic_or_pir_mode():
return _C_ops.asin(x)
else:
check_variable_and_dtype(
Expand Down Expand Up @@ -383,7 +383,7 @@ def asinh(x, name=None):
Tensor(shape=[4], dtype=float32, place=Place(cpu), stop_gradient=True,
[-0.39003533, -0.19869010, 0.09983408, 0.29567307])
"""
if in_dynamic_mode():
if in_dynamic_or_pir_mode():
return _C_ops.asinh(x)
else:
check_variable_and_dtype(
Expand Down
22 changes: 15 additions & 7 deletions test/legacy_test/test_activation_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -2147,10 +2147,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)


class TestAsin_Complex64(TestAsin):
Expand Down Expand Up @@ -2244,14 +2247,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 or self.dtype == np.complex128:
# Complex64 [CPU]: AssertionError: 0.006898686 not less than or equal to 0.005
self.check_grad(['X'], 'Out', max_relative_error=0.007)
self.check_grad(
['X'], 'Out', max_relative_error=0.007, check_pir=True
)
else:
self.check_grad(['X'], 'Out')
self.check_grad(['X'], 'Out', check_pir=True)


class TestAsinh_Complex64(TestAsinh):
Expand Down Expand Up @@ -4727,10 +4735,10 @@ def test_check_grad(self):
create_test_act_fp16_class(TestAcos, check_pir=True)
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(TestAsin, check_pir=True)
create_test_act_fp16_class(TestAtan)
create_test_act_fp16_class(TestAcosh, check_pir=True)
create_test_act_fp16_class(TestAsinh)
create_test_act_fp16_class(TestAsinh, check_pir=True)
create_test_act_fp16_class(TestAtanh)
create_test_act_fp16_class(TestRound, grad_check=False, check_pir=True)
create_test_act_fp16_class(
Expand Down Expand Up @@ -4881,10 +4889,10 @@ def test_check_grad(self):
create_test_act_bf16_class(TestAcos, check_pir=True)
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(TestAsin, check_pir=True)
create_test_act_bf16_class(TestAtan)
create_test_act_bf16_class(TestAcosh, check_pir=True)
create_test_act_bf16_class(TestAsinh)
create_test_act_bf16_class(TestAsinh, check_pir=True)
create_test_act_bf16_class(TestAtanh)
create_test_act_bf16_class(TestRound, grad_check=False, check_pir=True)
create_test_act_bf16_class(TestRelu, check_prim=True, check_pir=True)
Expand Down