| @@ -199,6 +199,9 @@ MS_REG_GPU_KERNEL_ONE( | |||
| MS_REG_GPU_KERNEL_ONE( | |||
| Div, KernelAttr().AddInputAttr(kNumberTypeInt32).AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeInt32), | |||
| BroadcastOpGpuKernel, int) | |||
| MS_REG_GPU_KERNEL_ONE( | |||
| RealDiv, KernelAttr().AddInputAttr(kNumberTypeInt32).AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeInt32), | |||
| BroadcastOpGpuKernel, int) | |||
| MS_REG_GPU_KERNEL_ONE( | |||
| DivNoNan, KernelAttr().AddInputAttr(kNumberTypeInt32).AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeInt32), | |||
| BroadcastOpGpuKernel, int) | |||
| @@ -516,7 +516,8 @@ def linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None, axis | |||
| iota_shape = _tuple_slice(iota_shape, None, axis) + (num,) + _tuple_slice(iota_shape, axis+1, None) | |||
| num_tensor = _type_convert(Tensor, num).astype(mstype.float32) | |||
| div = (num_tensor - 1) if endpoint else num_tensor | |||
| out = None | |||
| delta = None | |||
| if num > 1: | |||
| delta = (stop - start) / div | |||
| # This is similar to how numpy and jax compute linspace | |||
| @@ -530,8 +531,7 @@ def linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None, axis | |||
| delta = nan if endpoint else stop - start | |||
| out = reshape(start, bounds_shape) | |||
| else: # num == 0 | |||
| delta = nan | |||
| out = _type_convert(Tensor, []).astype(dtype) | |||
| _raise_value_error("cannot support Tensor with num=0.") | |||
| if retstep: | |||
| return out.astype(dtype), delta | |||
| return out.astype(dtype) | |||
| @@ -631,7 +631,7 @@ def geomspace(start, stop, num=50, endpoint=True, dtype=None, axis=0): | |||
| root = num | |||
| if endpoint: | |||
| root -= 1 | |||
| bases = F.tensor_pow(F.tensor_div(stop, start), asarray_const(1/(root))) | |||
| bases = F.tensor_pow(F.tensor_div(stop, start), asarray_const(1./(root))) | |||
| exponents = linspace(zeros(F.shape(bases)), F.fill(F.dtype(bases), F.shape(bases), root), | |||
| num, endpoint=endpoint, dtype=dtype, axis=axis) | |||
| shape = F.shape(bases) | |||
| @@ -1422,6 +1422,8 @@ def _split(x, indices_or_sections, opname, axis=0): | |||
| arr_shape = x.shape | |||
| length_along_dim = arr_shape[axis] | |||
| if isinstance(indices_or_sections, int): | |||
| if indices_or_sections > length_along_dim: | |||
| _raise_value_error("empty tensor encountered.") | |||
| if opname == "split" or length_along_dim % indices_or_sections == 0: | |||
| res = P.Split(axis, indices_or_sections)(x) | |||
| else: | |||
| @@ -1461,6 +1463,8 @@ def _split_sub_tensors(x, indices, axis): | |||
| for i, idx in enumerate(indices): | |||
| begin[axis] = 0 if i == 0 else indices[i-1] | |||
| end[axis] = idx | |||
| if end[axis] <= begin[axis]: | |||
| _raise_value_error("empty sub-tensor encountered.") | |||
| sliced_tensor = F.strided_slice(x, _type_convert(tuple, begin), _type_convert(tuple, end), strides) | |||
| sub_tensors.append(sliced_tensor) | |||
| return sub_tensors | |||
| @@ -2136,19 +2140,19 @@ def choose(a, choices, mode='clip'): | |||
| with ``shape Ba.shape`` is created as follows: | |||
| - if ``mode='raise'`` (the default), then, first of all, each element of `a` | |||
| (and thus `Ba`) must be in the range `[0, n-1]`; now, suppose that `i` | |||
| (in that range) is the value at the `(j0, j1, ..., jm)` position in | |||
| `Ba` - then the value at the same position in the new array is the | |||
| value in ``Bchoices[i]`` at that same position; | |||
| (and thus `Ba`) must be in the range `[0, n-1]`; now, suppose that `i` | |||
| (in that range) is the value at the `(j0, j1, ..., jm)` position in | |||
| `Ba` - then the value at the same position in the new array is the | |||
| value in ``Bchoices[i]`` at that same position; | |||
| - if ``mode='wrap'``, values in `a` (and thus `Ba`) may be any (signed) | |||
| integer; modular arithmetic is used to map integers outside the | |||
| range ``[0, n-1]`` back into that range; and then the new array is | |||
| constructed as above; | |||
| integer; modular arithmetic is used to map integers outside the | |||
| range ``[0, n-1]`` back into that range; and then the new array is | |||
| constructed as above; | |||
| - if ``mode='clip'``, values in `a` (and thus `Ba`) may be any (signed) integer; | |||
| negative integers are mapped to 0; values greater than `n-1` are mapped to | |||
| `n-1`; and then the new array is constructed as above. | |||
| negative integers are mapped to 0; values greater than `n-1` are mapped to | |||
| `n-1`; and then the new array is constructed as above. | |||
| Note: | |||
| Numpy argument `out` is not supported. | |||
| @@ -5645,10 +5645,10 @@ def bitwise_and(x1, x2, dtype=None): | |||
| def bitwise_or(x1, x2, dtype=None): | |||
| """ | |||
| r""" | |||
| Computes the bit-wise OR of two arrays element-wise. | |||
| Computes the bit-wise OR of the underlying binary representation of the integers in | |||
| the input arrays. This ufunc implements the C/Python operator |. | |||
| the input arrays. This ufunc implements the C/Python operator \|. | |||
| Note: | |||
| Numpy arguments `out`, `where`, `casting`, `order`, `subok`, `signature`, and `extobj` are | |||