Skip to content

Commit

Permalink
[PIR] Migrate paddle.floor into pir (PaddlePaddle#58093)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioLulab authored and jiahy0825 committed Oct 26, 2023
1 parent 8c9e20b commit 9e1eeaa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion python/paddle/tensor/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ def floor(x, name=None):
Tensor(shape=[4], dtype=float32, place=Place(cpu), stop_gradient=True,
[-1., -1., 0., 0.])
"""
if in_dynamic_mode():
if in_dynamic_or_pir_mode():
return _C_ops.floor(x)
else:
check_variable_and_dtype(
Expand Down
14 changes: 12 additions & 2 deletions test/legacy_test/test_activation_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -1814,6 +1814,9 @@ def init_shape(self):
def if_enable_cinn(self):
pass

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

# the gradient on floor, ceil, round is undefined.
# we return zero as gradient, but the numpy return nan
# The same reason with TestFloor
Expand All @@ -1832,6 +1835,7 @@ def test_check_grad_for_prim(self):
'Out',
check_prim=True,
only_check_prim=True,
check_pir=True,
)


Expand Down Expand Up @@ -4658,7 +4662,11 @@ def test_check_grad(self):
)
create_test_act_fp16_class(TestCeil, grad_check=False, check_pir=True)
create_test_act_fp16_class(
TestFloor, check_prim=True, grad_check=False, enable_cinn=True
TestFloor,
check_prim=True,
grad_check=False,
enable_cinn=True,
check_pir=True,
)
create_test_act_fp16_class(TestCos)
create_test_act_fp16_class(TestTan)
Expand Down Expand Up @@ -4809,7 +4817,9 @@ def test_check_grad(self):
)
create_test_act_bf16_class(TestAbs, check_prim=True, check_pir=True)
create_test_act_bf16_class(TestCeil, grad_check=False, check_pir=True)
create_test_act_bf16_class(TestFloor, grad_check=False, check_prim=True)
create_test_act_bf16_class(
TestFloor, grad_check=False, check_prim=True, check_pir=True
)
create_test_act_bf16_class(TestCos)
create_test_act_bf16_class(TestTan)
create_test_act_bf16_class(TestCosh)
Expand Down

0 comments on commit 9e1eeaa

Please sign in to comment.