Skip to contents

Creates an initial RNG state from a seed. This state is required by all random sampling functions and is updated after each call.

Usage

nv_rng_state(seed, device = default_device())

Arguments

seed

(arrayish)
Scalar i32 seed value.

device

(NULL | character(1) | device)
The device the data lives on, given either as:

  • a device string naming the platform (e.g. "cpu", "cuda", "cuda:<n>"), which is resolved against the backend in use, or

  • a device object as returned by nv_device(): a PJRTDevice for the "pjrt" backend or a quickr_device for the "quickr" backend. Because a device object is backend-specific, it also determines the backend.

The default (NULL) uses default_device(): the CPU, or the platform named by the PJRT_PLATFORM environment variable on the "pjrt" backend.

Value

nv_array of dtype ui64 and shape (2).

Examples

state <- nv_rng_state(42L)
state
#> AnvlArray
#>  42
#>   0
#> [ CPUui64{2} ]