Skip to content

Commit

Permalink
[PIR] Migrate paddle.round into pir (PaddlePaddle#58005)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioLulab authored and jiahy0825 committed Oct 26, 2023
1 parent 9e1eeaa commit e8b1879
Show file tree
Hide file tree
Showing 3 changed files with 22 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 @@ -839,7 +839,7 @@ def round(x, name=None):
Tensor(shape=[4], dtype=float32, place=Place(cpu), stop_gradient=True,
[-1., -0., 1., 2.])
"""
if in_dynamic_mode():
if in_dynamic_or_pir_mode():
return _C_ops.round(x)
else:
check_variable_and_dtype(
Expand Down
7 changes: 5 additions & 2 deletions test/legacy_test/test_activation_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -2296,6 +2296,9 @@ 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):
pass

Expand Down Expand Up @@ -4679,7 +4682,7 @@ def test_check_grad(self):
create_test_act_fp16_class(TestAcosh)
create_test_act_fp16_class(TestAsinh)
create_test_act_fp16_class(TestAtanh)
create_test_act_fp16_class(TestRound, grad_check=False)
create_test_act_fp16_class(TestRound, grad_check=False, check_pir=True)
create_test_act_fp16_class(
TestRelu, check_prim=True, enable_cinn=True, check_pir=True
)
Expand Down Expand Up @@ -4831,7 +4834,7 @@ def test_check_grad(self):
create_test_act_bf16_class(TestAcosh)
create_test_act_bf16_class(TestAsinh)
create_test_act_bf16_class(TestAtanh)
create_test_act_bf16_class(TestRound, grad_check=False)
create_test_act_bf16_class(TestRound, grad_check=False, check_pir=True)
create_test_act_bf16_class(TestRelu, check_prim=True, check_pir=True)
create_test_act_bf16_class(
TestGelu,
Expand Down
16 changes: 16 additions & 0 deletions test/mkldnn/test_activation_mkldnn_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,14 @@ def setUp(self):
self.outputs = {'Out': out}
self.attrs = {"use_mkldnn": True}

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', check_pir=True)


class TestMKLDNNRound_ZeroDim(TestActivation_ZeroDim):
def setUp(self):
Expand All @@ -494,6 +502,14 @@ def setUp(self):
self.outputs = {'Out': out}
self.attrs = {"use_mkldnn": True}

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', check_pir=True)


class TestMKLDNNSigmoidDim4(TestSigmoid):
def setUp(self):
Expand Down

0 comments on commit e8b1879

Please sign in to comment.