From 5022dd9b02f12703e41d91bf95fe8839652e1c46 Mon Sep 17 00:00:00 2001 From: Nyakku Shigure Date: Thu, 15 Sep 2022 16:21:03 +0800 Subject: [PATCH] [CodeStyle][W291] trim trailing whitespace in NPU unittest file (#46042) --- python/paddle/fluid/framework.py | 11 +++++++---- .../tests/unittests/npu/test_tril_triu_op_npu.py | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/python/paddle/fluid/framework.py b/python/paddle/fluid/framework.py index a4400d6272..5747de7ddd 100644 --- a/python/paddle/fluid/framework.py +++ b/python/paddle/fluid/framework.py @@ -1160,19 +1160,22 @@ def grad_var_name(var_name): def convert_np_dtype_to_dtype_(np_dtype): """ - Convert the data type in numpy to the data type in Paddle + Convert the data type in numpy to the data type in Paddle. Args: - np_dtype(np.dtype): the data type in numpy. + np_dtype (np.dtype|str): The data type in numpy or valid data type + string. Returns: - core.VarDesc.VarType: the data type in Paddle. + core.VarDesc.VarType: The data type in Paddle. """ - if np_dtype == "bfloat16": + # Convert the data type string to numpy data type. + if isinstance(np_dtype, str) and np_dtype == "bfloat16": dtype = np.uint16 else: dtype = np.dtype(np_dtype) + if dtype == np.float32: return core.VarDesc.VarType.FP32 elif dtype == np.float64: 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 f62c5b47d5..2bd374fe6d 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 @@ -135,7 +135,7 @@ for _op_type in ['tril', 'triu']: class TestTrilTriuOpAPI(unittest.TestCase): - """ test case by using API and has -1 dimension + """ test case by using API and has -1 dimension """ def test_api(self): -- GitLab