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:
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
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,))
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 – The desired datatype of the tensor.
- Returns:
A tensor of shape \([\text{stop}]\).
- Return type:
Example
1output = tp.arange(5)
>>> output tensor([0.0000, 1.0000, 2.0000, 3.0000, 4.0000], dtype=float32, loc=gpu:0, shape=(5,))