From 5ea6b988449cf806c5ab45c79097e36d9348b82e Mon Sep 17 00:00:00 2001 From: enkilee Date: Wed, 24 Jan 2024 14:39:31 +0800 Subject: [PATCH 01/11] fix --- test/legacy_test/test_transpose_op.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/legacy_test/test_transpose_op.py b/test/legacy_test/test_transpose_op.py index 1ba2c4b980741..c1eb6a0a4eed5 100644 --- a/test/legacy_test/test_transpose_op.py +++ b/test/legacy_test/test_transpose_op.py @@ -21,7 +21,7 @@ import paddle from paddle import base -from paddle.base import Program, core, program_guard +from paddle.base import core from paddle.pir_utils import test_with_pir_api paddle.enable_static() @@ -499,9 +499,12 @@ def initTestCase(self): class TestTransposeOpError(unittest.TestCase): + @test_with_pir_api def test_errors(self): paddle.enable_static() - with program_guard(Program(), Program()): + with paddle.static.program_guard( + paddle.static.Program(), paddle.static.Program() + ): x = paddle.static.data( name='x', shape=[-1, 10, 5, 3], dtype='float64' ) From 1296736620aa357ea9130c1e83e64287c7384c00 Mon Sep 17 00:00:00 2001 From: enkilee Date: Thu, 25 Jan 2024 09:32:58 +0800 Subject: [PATCH 02/11] fix --- test/legacy_test/test_transpose_op.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/legacy_test/test_transpose_op.py b/test/legacy_test/test_transpose_op.py index c1eb6a0a4eed5..de80f12eba344 100644 --- a/test/legacy_test/test_transpose_op.py +++ b/test/legacy_test/test_transpose_op.py @@ -522,7 +522,7 @@ def test_x_dtype_check(): ) paddle.transpose(x1, perm=[1, 0, 2]) - self.assertRaises(TypeError, test_x_dtype_check) + self.assertRaises(RuntimeError, test_x_dtype_check) def test_perm_list_check(): # Input(perm)'s type must be list From eccf2cb91c63f9095d96a046a320134eabdb538f Mon Sep 17 00:00:00 2001 From: enkilee Date: Thu, 25 Jan 2024 10:19:30 +0800 Subject: [PATCH 03/11] fix --- test/legacy_test/test_transpose_op.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/legacy_test/test_transpose_op.py b/test/legacy_test/test_transpose_op.py index de80f12eba344..c1eb6a0a4eed5 100644 --- a/test/legacy_test/test_transpose_op.py +++ b/test/legacy_test/test_transpose_op.py @@ -522,7 +522,7 @@ def test_x_dtype_check(): ) paddle.transpose(x1, perm=[1, 0, 2]) - self.assertRaises(RuntimeError, test_x_dtype_check) + self.assertRaises(TypeError, test_x_dtype_check) def test_perm_list_check(): # Input(perm)'s type must be list From 37618530870316009e37736032cfc4bee5749b97 Mon Sep 17 00:00:00 2001 From: enkilee Date: Fri, 26 Jan 2024 14:32:26 +0800 Subject: [PATCH 04/11] fix --- test/legacy_test/test_transpose_op.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/test/legacy_test/test_transpose_op.py b/test/legacy_test/test_transpose_op.py index c1eb6a0a4eed5..9a95f7660c89d 100644 --- a/test/legacy_test/test_transpose_op.py +++ b/test/legacy_test/test_transpose_op.py @@ -22,6 +22,9 @@ import paddle from paddle import base from paddle.base import core +from paddle.framework import ( + in_pir_mode, +) from paddle.pir_utils import test_with_pir_api paddle.enable_static() @@ -515,14 +518,16 @@ def test_x_Variable_check(): self.assertRaises(TypeError, test_x_Variable_check) - def test_x_dtype_check(): - # the Input(x)'s dtype must be one of [bool, float16, float32, float64, int32, int64] - x1 = paddle.static.data( - name='x1', shape=[-1, 10, 5, 3], dtype='int8' - ) - paddle.transpose(x1, perm=[1, 0, 2]) + if not in_pir_mode(): - self.assertRaises(TypeError, test_x_dtype_check) + def test_x_dtype_check(): + # the Input(x)'s dtype must be one of [bool, float16, float32, float64, int32, int64] + x1 = paddle.static.data( + name='x1', shape=[-1, 10, 5, 3], dtype='int8' + ) + paddle.transpose(x1, perm=[1, 0, 2]) + + self.assertRaises(TypeError, test_x_dtype_check) def test_perm_list_check(): # Input(perm)'s type must be list From deb19b0bf137e0d36dbe1268e47252e43ad0f224 Mon Sep 17 00:00:00 2001 From: enkilee Date: Mon, 29 Jan 2024 16:29:44 +0800 Subject: [PATCH 05/11] fix --- python/paddle/tensor/linalg.py | 3 ++- test/legacy_test/test_transpose_op.py | 19 +++++++------------ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/python/paddle/tensor/linalg.py b/python/paddle/tensor/linalg.py index 321366276c611..bd137122463c1 100644 --- a/python/paddle/tensor/linalg.py +++ b/python/paddle/tensor/linalg.py @@ -52,7 +52,7 @@ def transpose(x, perm, name=None): perm[i]-th dimension of `input`. Args: - x (Tensor): The input Tensor. It is a N-D Tensor of data types bool, float32, float64, int32. + x (Tensor): The input Tensor. It is a N-D Tensor of data types bool, float16, float32, float64, int8, int32, int64. perm (list|tuple): Permute the input according to the data of perm. name (str, optional): The name of this layer. For more information, please refer to :ref:`api_guide_Name`. Default is None. @@ -121,6 +121,7 @@ def transpose(x, perm, name=None): 'float16', 'float32', 'float64', + 'int8', 'int32', 'int64', 'uint16', diff --git a/test/legacy_test/test_transpose_op.py b/test/legacy_test/test_transpose_op.py index 9a95f7660c89d..00136683e30dc 100644 --- a/test/legacy_test/test_transpose_op.py +++ b/test/legacy_test/test_transpose_op.py @@ -22,9 +22,6 @@ import paddle from paddle import base from paddle.base import core -from paddle.framework import ( - in_pir_mode, -) from paddle.pir_utils import test_with_pir_api paddle.enable_static() @@ -518,16 +515,14 @@ def test_x_Variable_check(): self.assertRaises(TypeError, test_x_Variable_check) - if not in_pir_mode(): + def test_x_dtype_check(): + # the Input(x)'s dtype must be one of [bool, float16, float32, float64, int8, int32, int64] + x1 = paddle.static.data( + name='x1', shape=[-1, 10, 5, 3], dtype='int16' + ) + paddle.transpose(x1, perm=[1, 0, 2]) - def test_x_dtype_check(): - # the Input(x)'s dtype must be one of [bool, float16, float32, float64, int32, int64] - x1 = paddle.static.data( - name='x1', shape=[-1, 10, 5, 3], dtype='int8' - ) - paddle.transpose(x1, perm=[1, 0, 2]) - - self.assertRaises(TypeError, test_x_dtype_check) + self.assertRaises(TypeError, test_x_dtype_check) def test_perm_list_check(): # Input(perm)'s type must be list From 42765bef4a98a46c6b8e1fe56dc6e909c639e67a Mon Sep 17 00:00:00 2001 From: enkilee Date: Tue, 30 Jan 2024 16:11:06 +0800 Subject: [PATCH 06/11] fix --- python/paddle/tensor/linalg.py | 6 ++++-- test/legacy_test/test_transpose_op.py | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/python/paddle/tensor/linalg.py b/python/paddle/tensor/linalg.py index bd137122463c1..40cbf2993ad92 100644 --- a/python/paddle/tensor/linalg.py +++ b/python/paddle/tensor/linalg.py @@ -52,7 +52,7 @@ def transpose(x, perm, name=None): perm[i]-th dimension of `input`. Args: - x (Tensor): The input Tensor. It is a N-D Tensor of data types bool, float16, float32, float64, int8, int32, int64. + x (Tensor): The input Tensor. It is a N-D Tensor of data types bool, float16, bfloat16, float32, float64, int8, int16, int32, int64, uint8, complex64, complex128. perm (list|tuple): Permute the input according to the data of perm. name (str, optional): The name of this layer. For more information, please refer to :ref:`api_guide_Name`. Default is None. @@ -119,12 +119,14 @@ def transpose(x, perm, name=None): [ 'bool', 'float16', + 'bfloat16', 'float32', 'float64', 'int8', + 'uint8', + 'int16', 'int32', 'int64', - 'uint16', 'complex64', 'complex128', ], diff --git a/test/legacy_test/test_transpose_op.py b/test/legacy_test/test_transpose_op.py index 00136683e30dc..6439fe418ae7c 100644 --- a/test/legacy_test/test_transpose_op.py +++ b/test/legacy_test/test_transpose_op.py @@ -516,9 +516,9 @@ def test_x_Variable_check(): self.assertRaises(TypeError, test_x_Variable_check) def test_x_dtype_check(): - # the Input(x)'s dtype must be one of [bool, float16, float32, float64, int8, int32, int64] + # the Input(x)'s dtype must be one of [bool, float16, bfloat16, float32, float64, int8, int16, int32, int64, uint8, complex64, complex128] x1 = paddle.static.data( - name='x1', shape=[-1, 10, 5, 3], dtype='int16' + name='x1', shape=[-1, 10, 5, 3], dtype='uint16' ) paddle.transpose(x1, perm=[1, 0, 2]) From 487ee8f856c6f19919226d7f687b1e6cd8919710 Mon Sep 17 00:00:00 2001 From: enkilee Date: Wed, 31 Jan 2024 11:32:41 +0800 Subject: [PATCH 07/11] fix --- python/paddle/tensor/linalg.py | 3 ++- test/legacy_test/test_transpose_op.py | 12 +++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/python/paddle/tensor/linalg.py b/python/paddle/tensor/linalg.py index 40cbf2993ad92..67ca945642385 100644 --- a/python/paddle/tensor/linalg.py +++ b/python/paddle/tensor/linalg.py @@ -52,7 +52,7 @@ def transpose(x, perm, name=None): perm[i]-th dimension of `input`. Args: - x (Tensor): The input Tensor. It is a N-D Tensor of data types bool, float16, bfloat16, float32, float64, int8, int16, int32, int64, uint8, complex64, complex128. + x (Tensor): The input Tensor. It is a N-D Tensor of data types bool, float16, bfloat16, float32, float64, int8, int16, int32, int64, uint8, uint16, complex64, complex128. perm (list|tuple): Permute the input according to the data of perm. name (str, optional): The name of this layer. For more information, please refer to :ref:`api_guide_Name`. Default is None. @@ -127,6 +127,7 @@ def transpose(x, perm, name=None): 'int16', 'int32', 'int64', + 'uint16', 'complex64', 'complex128', ], diff --git a/test/legacy_test/test_transpose_op.py b/test/legacy_test/test_transpose_op.py index 6439fe418ae7c..5a5698b1275cd 100644 --- a/test/legacy_test/test_transpose_op.py +++ b/test/legacy_test/test_transpose_op.py @@ -515,14 +515,12 @@ def test_x_Variable_check(): self.assertRaises(TypeError, test_x_Variable_check) - def test_x_dtype_check(): - # the Input(x)'s dtype must be one of [bool, float16, bfloat16, float32, float64, int8, int16, int32, int64, uint8, complex64, complex128] - x1 = paddle.static.data( - name='x1', shape=[-1, 10, 5, 3], dtype='uint16' + if core.is_complied_with_cuda(): + # the Input(x)'s dtype must be one of [bool, float16, bfloat16, float32, float64, int8, int16, int32, int64, uint8, uint16, complex64, complex128] + x_fp16 = paddle.static.data( + name='x1', shape=[-1, 10, 5, 3], dtype='float16' ) - paddle.transpose(x1, perm=[1, 0, 2]) - - self.assertRaises(TypeError, test_x_dtype_check) + self.transpose(x_fp16, perm=[1, 0, 2]) def test_perm_list_check(): # Input(perm)'s type must be list From e300fcc3037cc5e4ca317321d23e344146942ba7 Mon Sep 17 00:00:00 2001 From: enkilee Date: Thu, 1 Feb 2024 14:36:49 +0800 Subject: [PATCH 08/11] fix --- test/legacy_test/test_transpose_op.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/legacy_test/test_transpose_op.py b/test/legacy_test/test_transpose_op.py index 5a5698b1275cd..8ed0a39e69c9e 100644 --- a/test/legacy_test/test_transpose_op.py +++ b/test/legacy_test/test_transpose_op.py @@ -515,7 +515,7 @@ def test_x_Variable_check(): self.assertRaises(TypeError, test_x_Variable_check) - if core.is_complied_with_cuda(): + if core.is_compiled_with_cuda(): # the Input(x)'s dtype must be one of [bool, float16, bfloat16, float32, float64, int8, int16, int32, int64, uint8, uint16, complex64, complex128] x_fp16 = paddle.static.data( name='x1', shape=[-1, 10, 5, 3], dtype='float16' From d0cf948f09106c2245ce2a31a714872bb6e6e8af Mon Sep 17 00:00:00 2001 From: enkilee Date: Thu, 1 Feb 2024 17:06:37 +0800 Subject: [PATCH 09/11] fix --- test/legacy_test/test_transpose_op.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/legacy_test/test_transpose_op.py b/test/legacy_test/test_transpose_op.py index 8ed0a39e69c9e..f742722fe6a37 100644 --- a/test/legacy_test/test_transpose_op.py +++ b/test/legacy_test/test_transpose_op.py @@ -520,7 +520,7 @@ def test_x_Variable_check(): x_fp16 = paddle.static.data( name='x1', shape=[-1, 10, 5, 3], dtype='float16' ) - self.transpose(x_fp16, perm=[1, 0, 2]) + paddle.transpose(x_fp16, perm=[1, 0, 2]) def test_perm_list_check(): # Input(perm)'s type must be list From 1ff520681c6c8e15f22bbb0a3e3a247862a5b026 Mon Sep 17 00:00:00 2001 From: enkilee Date: Fri, 2 Feb 2024 16:32:27 +0800 Subject: [PATCH 10/11] fix --- test/legacy_test/test_transpose_op.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/test/legacy_test/test_transpose_op.py b/test/legacy_test/test_transpose_op.py index f742722fe6a37..d779e4bd7f398 100644 --- a/test/legacy_test/test_transpose_op.py +++ b/test/legacy_test/test_transpose_op.py @@ -515,13 +515,6 @@ def test_x_Variable_check(): self.assertRaises(TypeError, test_x_Variable_check) - if core.is_compiled_with_cuda(): - # the Input(x)'s dtype must be one of [bool, float16, bfloat16, float32, float64, int8, int16, int32, int64, uint8, uint16, complex64, complex128] - x_fp16 = paddle.static.data( - name='x1', shape=[-1, 10, 5, 3], dtype='float16' - ) - paddle.transpose(x_fp16, perm=[1, 0, 2]) - def test_perm_list_check(): # Input(perm)'s type must be list paddle.transpose(x, perm="[1, 0, 2]") From 7bc10e637647949b90cd9d839cf62498273afbb8 Mon Sep 17 00:00:00 2001 From: enkilee Date: Sun, 4 Feb 2024 15:04:44 +0800 Subject: [PATCH 11/11] CI