Skip to content

Commit

Permalink
[PIR]Migrate paddle.gelu into pir (#57317)
Browse files Browse the repository at this point in the history
  • Loading branch information
0x45f authored Sep 15, 2023
1 parent d499021 commit b4aab30
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion python/paddle/nn/functional/activation.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def gelu(x, approximate=False, name=None):
[ 0.84119201, 1.39957154]])
"""

if in_dynamic_mode():
if in_dynamic_or_pir_mode():
return _C_ops.gelu(x, approximate)
else:
check_variable_and_dtype(
Expand Down
10 changes: 6 additions & 4 deletions test/legacy_test/test_activation_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -2442,12 +2442,12 @@ def setUp(self):
self.cinn_atol = 1e-8

def test_check_output(self):
self.check_output(check_prim=True)
self.check_output(check_prim=True, check_new_ir=True)

def test_check_grad(self):
if self.dtype == np.float16:
return
self.check_grad(['X'], 'Out', check_prim=True)
self.check_grad(['X'], 'Out', check_prim=True, check_new_ir=True)


class TestGelu(TestActivation):
Expand Down Expand Up @@ -2480,12 +2480,12 @@ def if_enable_cinn(self):
pass

def test_check_output(self):
self.check_output(check_prim=True)
self.check_output(check_prim=True, check_new_ir=True)

def test_check_grad(self):
if self.dtype == np.float16:
return
self.check_grad(['X'], 'Out', check_prim=True)
self.check_grad(['X'], 'Out', check_prim=True, check_new_ir=True)


class TestGelu_ZeroDim(TestGelu):
Expand Down Expand Up @@ -4466,6 +4466,7 @@ def test_check_grad(self):
create_test_act_fp16_class(
TestGelu,
check_prim=True,
check_new_ir=True,
enable_cinn=True,
rev_comp_rtol=1e-3,
rev_comp_atol=1e-3,
Expand Down Expand Up @@ -4595,6 +4596,7 @@ def test_check_grad(self):
create_test_act_bf16_class(
TestGelu,
check_prim=True,
check_new_ir=True,
rev_comp_rtol=1e-2,
rev_comp_atol=1e-2,
cinn_rtol=1e-2,
Expand Down

0 comments on commit b4aab30

Please sign in to comment.