arange

nvtripy.arange(*args, **kwargs) Tensor[source]

This function has multiple overloads:


nvtripy.arange(start: numbers.Number | nvtripy.DimensionSize, stop: numbers.Number | nvtripy.DimensionSize, step: numbers.Number | nvtripy.DimensionSize = 1, dtype: nvtripy.dtype = float32) -> nvtripy.Tensor

Returns a 1D tensor containing a sequence of numbers in the half-open interval \([\text{start}, \text{stop})\) incrementing by \(\text{step}\).

Parameters:
  • start – The inclusive lower bound of the values to generate. If a tensor is provided, it must be a scalar tensor.

  • stop – The exclusive upper bound of the values to generate. If a tensor is provided, it must be a scalar tensor.

  • step – The spacing between values. If a tensor is provided, it must be a scalar tensor.

  • dtype – [dtype=T1] The desired data type of the tensor.

Returns:

[dtype=T1] A tensor of shape \([\frac{\text{stop}-\text{start}}{\text{step}}]\).

Return type:

Tensor

DATA TYPE CONSTRAINTS:
Example
1output = tp.arange(0.5, 2.5)
Local Variables
>>> output
tensor([0.5, 1.5], dtype=float32, loc=gpu:0, shape=(2,))
Example: Custom ``step`` Value
1output = tp.arange(2.3, 0.8, -0.2)
Local Variables
>>> output
tensor([2.3, 2.1, 1.9, 1.7, 1.5, 1.3, 1.1, 0.9], dtype=float32, loc=gpu:0, shape=(8,))

nvtripy.arange(stop: numbers.Number | nvtripy.DimensionSize, dtype: nvtripy.dtype = float32) -> nvtripy.Tensor

Returns a 1D tensor containing a sequence of numbers in the half-open interval \([0, \text{stop})\) incrementing by 1.

Parameters:
  • stop – The exclusive upper bound of the values to generate.

  • dtype – [dtype=T1] The desired datatype of the tensor.

Returns:

[dtype=T1] A tensor of shape \([\text{stop}]\).

Return type:

Tensor

DATA TYPE CONSTRAINTS:
Example
1output = tp.arange(5)
Local Variables
>>> output
tensor([0, 1, 2, 3, 4], dtype=float32, loc=gpu:0, shape=(5,))