Skip to content

Commit

Permalink
[PIR]Migrate log into pir (PaddlePaddle#57946)
Browse files Browse the repository at this point in the history
  • Loading branch information
0x45f authored and jiahy0825 committed Oct 16, 2023
1 parent a8d9dea commit 53e1340
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion python/paddle/tensor/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def log(x, name=None):
[[0.69314718, 1.09861231, 1.38629436],
[1.94591010, 2.07944155, 2.19722462]])
"""
if in_dynamic_mode():
if in_dynamic_or_pir_mode():
return _C_ops.log(x)
else:
check_variable_and_dtype(
Expand Down
9 changes: 6 additions & 3 deletions test/legacy_test/test_activation_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -3257,10 +3257,13 @@ def setUp(self):
def if_enable_cinn(self):
pass

def test_check_output(self):
self.check_output(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 Test_Log_Op_Fp16(unittest.TestCase):
Expand Down Expand Up @@ -4608,7 +4611,7 @@ def test_check_grad(self):
create_test_act_fp16_class(TestELU)
create_test_act_fp16_class(TestCELU)
create_test_act_fp16_class(TestReciprocal)
create_test_act_fp16_class(TestLog, check_prim=True)
create_test_act_fp16_class(TestLog, check_prim=True, check_new_ir=True)
if core.is_compiled_with_rocm():
create_test_act_fp16_class(TestLog2)
else:
Expand Down Expand Up @@ -4748,7 +4751,7 @@ def test_check_grad(self):
create_test_act_bf16_class(TestELU)
create_test_act_bf16_class(TestCELU)
create_test_act_bf16_class(TestReciprocal)
create_test_act_bf16_class(TestLog, check_prim=True)
create_test_act_bf16_class(TestLog, check_prim=True, check_new_ir=True)
if core.is_compiled_with_rocm():
create_test_act_bf16_class(TestLog2)
else:
Expand Down

0 comments on commit 53e1340

Please sign in to comment.