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

[NewIR] No.49 Migrate paddle.tril into pir #57393

Merged
merged 6 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 3 additions & 2 deletions python/paddle/tensor/creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
convert_np_dtype_to_dtype_,
core,
in_dynamic_mode,
in_dynamic_or_pir_mode,
in_pir_mode,
)

Expand Down Expand Up @@ -1511,7 +1512,7 @@ def tril(x, diagonal=0, name=None):
[5 , 0 , 0 , 0 ],
[9 , 10, 0 , 0 ]])
"""
if in_dynamic_mode():
if in_dynamic_or_pir_mode():
return _C_ops.tril(x, diagonal)
else:
return _tril_triu_op(LayerHelper('tril', **locals()))
Expand Down Expand Up @@ -1588,7 +1589,7 @@ def triu(x, diagonal=0, name=None):
[0 , 10, 11, 12]])

"""
if in_dynamic_mode():
if in_dynamic_or_pir_mode():
return _C_ops.triu(x, diagonal)
else:
return _tril_triu_op(LayerHelper('triu', **locals()))
Expand Down
12 changes: 8 additions & 4 deletions test/legacy_test/test_tril_triu_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ def setUp(self):
}

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

def test_check_grad_normal(self):
self.check_grad(['X'], 'Out')
self.check_grad(['X'], 'Out', check_new_ir=True)

def init_dtype(self):
self.dtype = np.float64
Expand Down Expand Up @@ -86,11 +86,15 @@ def initTestCase(self):
self.X = np.arange(1, 101, dtype="float32").reshape([10, -1])

def test_check_output(self):
self.check_output_with_place(core.CUDAPlace(0))
self.check_output_with_place(core.CUDAPlace(0), check_new_ir=True)

def test_check_grad_normal(self):
self.check_grad_with_place(
core.CUDAPlace(0), ['X'], 'Out', numeric_grad_delta=0.05
core.CUDAPlace(0),
['X'],
'Out',
numeric_grad_delta=0.05,
check_new_ir=True,
)


Expand Down