mindspore.ops.range

mindspore.ops.range(start, limit, delta)[source]

Creates a sequence of numbers that begins at start and extends by increments of delta up to but not including limit.

The types of all 3 inputs must be the same. The type of the resulting tensor is the same as the type of the inputs.

Parameters
  • start (Tensor) – A scalar Tensor. The first number in the sequence. Must have type: int32 ,int64, float32 or float64.

  • limit (Tensor) – A scalar Tensor. Upper limit of the sequence, exclusive. Must have type: int32 ,int64, float32 or float64.

  • delta (Tensor) – A scalar Tensor. Number that increments start. Must have type: int32 ,int64, float32 or float64.

Returns

A 1-D Tensor, with the same type as the inputs.

Raises
  • TypeError – If start, limit or delta is not scalar Tensor.

  • TypeError – If datatype of start, limit or delta is not same.

  • TypeError – If datatype of start, limit or delta is not supported.

  • ValueError – If delta = 0.

  • ValueError – If start >= limit when delta > 0.

  • ValueError – If start <= limit when delta < 0.

Supported Platforms:

GPU CPU

Examples

>>> start = Tensor(0, mstype.int32)
>>> limit = Tensor(10, mstype.int32)
>>> delta = Tensor(4, mstype.int32)
>>> output = ops.range(start, limit, delta)
>>> print(output)
[0 4 8]