arange

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

This function has multiple overloads:


> arange (start: Union, stop: Union, step: Union = 1, dtype: tripy.dtype = float32) -> tripy.Tensor

Returns a 1D tensor containing a sequence of numbers in the half-open interval \([0, \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

TYPE CONSTRAINTS:
Example
Example
1output = tp.arange(0.5, 2.5)
>>> output
tensor([0.5000, 1.5000], dtype=float32, loc=gpu:0, shape=(2,))
Example: Custom ``step`` Value
Custom step Value
1output = tp.arange(2.3, 0.8, -0.2)
>>> output
tensor([2.3000, 2.1000, 1.9000, 1.7000, 1.5000, 1.3000, 1.1000, 0.9000], dtype=float32, loc=gpu:0, shape=(8,))

> arange (stop: Union, dtype: tripy.dtype = float32) -> tripy.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 – The desired datatype of the tensor.

Returns:

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

Return type:

Tensor

Example
Example
1output = tp.arange(5)
>>> output
tensor([0.0000, 1.0000, 2.0000, 3.0000, 4.0000], dtype=float32, loc=gpu:0, shape=(5,))