mindspore.ops.range

mindspore.ops.range(start, end, step, maxlen=1000000)[source]

Returns a tensor with a step length of step in the interval [ start , end ).

Note

  • The types of all 3 inputs must be all integers or floating-point numbers.

  • When the input is a tensor, the tensor must contain only one element, whose dtype is Number.

Warning

Non-backward-compatible change after version 2.9.0:

  • start and step will get default values 0 and 1 respectively.

  • Parameter maxlen will be removed.

The updated signature will be mindspore.ops.range(start=0, end, step=1).

Parameters
  • start (Union[Number, Tensor]) – The start value of the interval.

  • end (Union[Number, Tensor]) – The end value of the interval.

  • step (Union[Number, Tensor]) – The interval between each value.

  • maxlen (int, optional) – Memory that can fit maxlen many elements will be allocated for the output. Optional, must be positive. Default: 1000000. If the output has more than maxlen elements, a runtime error will occur.

Returns

Tensor

Supported Platforms:

GPU CPU

Examples

>>> import mindspore
>>> mindspore.ops.range(0, 6, 2)
Tensor(shape=[3], dtype=Int64, value= [0, 2, 4])