From ed33b860b6c97155128eccbd944d52a4a9af6f5e Mon Sep 17 00:00:00 2001 From: ccrrong <101700995+ccrrong@users.noreply.github.com> Date: Tue, 29 Nov 2022 10:49:28 +0800 Subject: [PATCH] remove triu from fluid (#48427) * remove triu * use paddle.triu --- python/paddle/fluid/layers/tensor.py | 8 -------- .../fluid/tests/unittests/mlu/test_tril_triu_op_mlu.py | 2 +- .../fluid/tests/unittests/npu/test_tril_triu_op_npu.py | 2 +- python/paddle/fluid/tests/unittests/test_tril_triu_op.py | 2 +- 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/python/paddle/fluid/layers/tensor.py b/python/paddle/fluid/layers/tensor.py index b7e0e60145..c5a28a913a 100644 --- a/python/paddle/fluid/layers/tensor.py +++ b/python/paddle/fluid/layers/tensor.py @@ -68,7 +68,6 @@ __all__ = [ 'zeros_like', 'ones_like', 'diag', - 'triu', ] @@ -1830,10 +1829,3 @@ def ones_like(x, out=None): outputs={'Out': [out]}, ) return out - - -@deprecated(since="2.0.0", update_to="paddle.triu") -def triu(input, diagonal=0, name=None): - import paddle - - return paddle.tensor.triu(x=input, diagonal=diagonal, name=name) diff --git a/python/paddle/fluid/tests/unittests/mlu/test_tril_triu_op_mlu.py b/python/paddle/fluid/tests/unittests/mlu/test_tril_triu_op_mlu.py index 2ed56de3c6..66b4a480bb 100644 --- a/python/paddle/fluid/tests/unittests/mlu/test_tril_triu_op_mlu.py +++ b/python/paddle/fluid/tests/unittests/mlu/test_tril_triu_op_mlu.py @@ -184,7 +184,7 @@ class TestTrilTriuOpAPI(unittest.TestCase): with program_guard(prog, startup_prog): data = np.random.random([1, 9, 9, 4]).astype(dtype) x = fluid.data(shape=[1, 9, -1, 4], dtype=dtype, name='x') - triu_out = fluid.layers.triu(x) + triu_out = paddle.triu(x) place = fluid.MLUPlace(0) exe = fluid.Executor(place) diff --git a/python/paddle/fluid/tests/unittests/npu/test_tril_triu_op_npu.py b/python/paddle/fluid/tests/unittests/npu/test_tril_triu_op_npu.py index aca61989b7..83ecf1f5a6 100644 --- a/python/paddle/fluid/tests/unittests/npu/test_tril_triu_op_npu.py +++ b/python/paddle/fluid/tests/unittests/npu/test_tril_triu_op_npu.py @@ -185,7 +185,7 @@ class TestTrilTriuOpAPI(unittest.TestCase): with program_guard(prog, startup_prog): data = np.random.random([1, 9, 9, 4]).astype(dtype) x = fluid.data(shape=[1, 9, -1, 4], dtype=dtype, name='x') - triu_out = fluid.layers.triu(x) + triu_out = paddle.triu(x) place = fluid.NPUPlace(0) exe = fluid.Executor(place) diff --git a/python/paddle/fluid/tests/unittests/test_tril_triu_op.py b/python/paddle/fluid/tests/unittests/test_tril_triu_op.py index b6473f66a4..b0b754dc96 100644 --- a/python/paddle/fluid/tests/unittests/test_tril_triu_op.py +++ b/python/paddle/fluid/tests/unittests/test_tril_triu_op.py @@ -183,7 +183,7 @@ class TestTrilTriuOpAPI(unittest.TestCase): with program_guard(prog, startup_prog): data = np.random.random([1, 9, 9, 4]).astype(dtype) x = fluid.data(shape=[1, 9, -1, 4], dtype=dtype, name='x') - triu_out = fluid.layers.triu(x) + triu_out = paddle.triu(x) place = ( fluid.CUDAPlace(0) -- GitLab