From 936bb237389b9bf9935abddc83b2a12663516561 Mon Sep 17 00:00:00 2001 From: Megvii Engine Team Date: Tue, 26 Oct 2021 15:43:05 +0800 Subject: [PATCH] fix(mge/tensor): fix is/is not SyntaxWarning occurs in python3.8 GitOrigin-RevId: 12b66da3675b6e418b161e7c301e40ca8302ea9f --- imperative/python/megengine/functional/tensor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/imperative/python/megengine/functional/tensor.py b/imperative/python/megengine/functional/tensor.py index a881fab14..0d17a6f3a 100755 --- a/imperative/python/megengine/functional/tensor.py +++ b/imperative/python/megengine/functional/tensor.py @@ -134,7 +134,7 @@ def full(shape, value, dtype="float32", device=None) -> Tensor: if device is None: device = get_default_device() (x,) = Const(value, dtype=dtype, device=device)() - if shape is (): # scalar.shape + if type(shape) in (list, tuple) and len(shape) == 0: return x return broadcast_to(x, shape) @@ -278,7 +278,7 @@ def full_like( """ (x,) = Const(value, dtype=inp.dtype, device=inp.device)(inp) - if inp.shape is (): + if inp.ndim == 0: return x return broadcast_to(x, inp.shape) -- GitLab