Creates an array filled with a scalar value. More memory-efficient than
nv_array(value, shape = shape) for large arrays.
nv_fill_like() is a variant where dtype, shape, ambiguous, and
device default to those of like.
Usage
nv_fill(value, shape, dtype = NULL, ambiguous = FALSE, device = NULL)
nv_fill_like(
like,
value,
shape = NULL,
dtype = NULL,
ambiguous = NULL,
device = NULL
)Arguments
- value
(
numeric(1))
Scalar value to fill the array with.- shape
(
integer())
Shape of the output array.- dtype
(
character(1)|NULL)
Data type.- 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 thevignette("type-promotion")for more details.- 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, ora device object as returned by
nv_device(): aPJRTDevicefor the"pjrt"backend or aquickr_devicefor the"quickr"backend. Because a device object is backend-specific, it also determines the backend.
The default (
NULL) usesdefault_device(): the CPU, or the platform named by thePJRT_PLATFORMenvironment variable on the"pjrt"backend.- like
(
AnvlArray)
Existing array whose attributes are used as defaults (only fornv_fill_like()).
Value
arrayish
Has the given shape and dtype.
See also
prim_fill() for the underlying primitive.