Browse Source

fix(mge/tensor): fix is/is not SyntaxWarning occurs in python3.8

GitOrigin-RevId: 12b66da367
release-1.7
Megvii Engine Team 3 years ago
parent
commit
936bb23738
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      imperative/python/megengine/functional/tensor.py

+ 2
- 2
imperative/python/megengine/functional/tensor.py View File

@@ -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)



Loading…
Cancel
Save