From 2de3599386fa613a723c2488665729acee69426d Mon Sep 17 00:00:00 2001 From: a162837 <1628373140@qq.com> Date: Mon, 18 Nov 2024 12:14:03 +0800 Subject: [PATCH] change name to clipmul --- python/paddle/tensor/math.py | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/python/paddle/tensor/math.py b/python/paddle/tensor/math.py index 9937245f343e9f..5156e9d0bdcf92 100644 --- a/python/paddle/tensor/math.py +++ b/python/paddle/tensor/math.py @@ -3798,13 +3798,7 @@ def clip( max_ = float(np.finfo(np.float32).max) tensor_dtype = 'float32' - if ( - isinstance(min, Variable) - and (len(min.shape) > 1 or (len(min.shape == 1) and min.shape[-1] != 1)) - ) or ( - isinstance(max, Variable) - and (len(max.shape) > 1 or (len(max.shape == 1) and max.shape[-1] != 1)) - ): + if (paddle.is_tensor(min) and min.numel() > 1) or (paddle.is_tensor(max) and max.numel() > 1): min = paddle.full_like(x, min_, tensor_dtype) if min is None else min max = paddle.full_like(x, max_, tensor_dtype) if max is None else max min = ( @@ -3949,13 +3943,7 @@ def clip_( fmax = float(np.finfo(np.float32).max) tensor_dtype = 'float32' - if ( - isinstance(min, Variable) - and (len(min.shape) > 1 or (len(min.shape == 1) and min.shape[-1] != 1)) - ) or ( - isinstance(max, Variable) - and (len(max.shape) > 1 or (len(max.shape == 1) and max.shape[-1] != 1)) - ): + if (paddle.is_tensor(min) and min.numel() > 1) or (paddle.is_tensor(max) and max.numel() > 1): min = paddle.full_like(x, fmin, tensor_dtype) if min is None else min max = paddle.full_like(x, fmax, tensor_dtype) if max is None else max min = (