Constructs a backend-specific device object for the active backend
(active_backend()).
A device identifies a compute resources, such as CPU, or a specific GPU.
It is relevant for data allocation (e.g. via nv_array()) but also compilation (jit).
A device belongs to the active backend (active_backend()); a device
object of another backend is an error.
Value
(device object)
Backend-specific (e.g. PJRTDevice for "pjrt",
quickr_device for "quickr").
Examples
# create CPU device for the active backend
nv_device("cpu")
#> <CpuDevice(id=0)>
# create CPU device for the quickr backend:
with_backend("quickr", nv_device("cpu"))
#> QuickrDevice(cpu)
# pass through an existing device:
dev <- nv_device("cpu")
identical(nv_device(dev), dev)
#> [1] TRUE