Browse Source

fix shape 0 in np.array

pull/14384/head
yanglf1121 4 years ago
parent
commit
fd2ca4c152
1 changed files with 2 additions and 0 deletions
  1. +2
    -0
      mindspore/numpy/utils_const.py

+ 2
- 0
mindspore/numpy/utils_const.py View File

@@ -450,6 +450,8 @@ def _tuple_setitem(tup, idx, value):
def _iota(dtype, num, increasing=True): def _iota(dtype, num, increasing=True):
"""Creates a 1-D tensor with value: [0,1,...num-1] and dtype.""" """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. # 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: if increasing:
return Tensor(list(range(int(num))), dtype) return Tensor(list(range(int(num))), dtype)
return Tensor(list(range(int(num)-1, -1, -1)), dtype) return Tensor(list(range(int(num)-1, -1, -1)), dtype)


Loading…
Cancel
Save