diff --git a/mindspore/numpy/utils_const.py b/mindspore/numpy/utils_const.py index c23d04b3c5..302e170a07 100644 --- a/mindspore/numpy/utils_const.py +++ b/mindspore/numpy/utils_const.py @@ -450,6 +450,8 @@ def _tuple_setitem(tup, idx, value): def _iota(dtype, num, increasing=True): """Creates a 1-D tensor with value: [0,1,...num-1] and dtype.""" # TODO: Change to P.Linspace when the kernel is implemented on CPU. + if num <= 0: + raise ValueError("zero shape Tensor is not currently supported.") if increasing: return Tensor(list(range(int(num))), dtype) return Tensor(list(range(int(num)-1, -1, -1)), dtype)