Skip to contents

Creates a tensor with values increasing along the specified dimension, starting from start.

Usage

nv_iota(dim, dtype, shape, start = 1L, ambiguous = FALSE)

Arguments

dim

(integer(1))
Dimension along which values increase.

dtype

(character(1) | stablehlo::TensorDataType)
Data type.

shape

(integer())
Shape.

start

(integer(1))
Starting value (default 1).

ambiguous

(logical(1))
Whether the type is ambiguous. Ambiguous types usually arise from R literals (e.g., 1L, 1.0) and follow special promotion rules. See the vignette("type-promotion") for more details.

Value

tensorish
Has the given dtype and shape.

See also

nv_seq() for a simpler 1-D sequence, nvl_iota() for the underlying primitive.

Examples

jit_eval(nv_iota(dim = 1L, dtype = "i32", shape = 5L))
#> AnvilTensor
#>  1
#>  2
#>  3
#>  4
#>  5
#> [ CPUi32{5} ]