提交 936bb237 编写于 作者: M Megvii Engine Team

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

GitOrigin-RevId: 12b66da3675b6e418b161e7c301e40ca8302ea9f
上级 8d507cc3
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册