Transfer buffer data from device to host and return an R array.
Usage
# S3 method for class 'PJRTBuffer'
as_array(x, check = "warn", ...)Arguments
- x
(
PJRTBuffer)
Buffer to convert.- check
(
character(1)|FALSE)
How to report a materialized value that R's type cannot hold:"warn"(the default) warns and returns it anyway,"err"aborts, andFALSEskips the scan altogether.TRUEis not accepted — with two levels of strictness it does not say which one is meant.The cases scanned for are:
i32/i64: anyNAin the result. R'sNA_integer_shares the bit patternINT_MIN;bit64'sNA_integer64_sharesINT64_MIN. A legitimate device value at those bit patterns is indistinguishable fromNAonce materialized in R.ui64: any negative value in the result.ui64is stored asbit64::integer64(signed 64-bit), which wraps values>= 2^63to negative — exactly2^63becomesNA_integer64_, anything above becomes a non-NA negative integer64.
Each case is a value the R type genuinely cannot hold, so the check has no false positives: it fires exactly when the returned vector would misrepresent the buffer.
No-op for float, boolean, and small/unsigned-32 integer dtypes —
ui32is stored asinteger64and has full headroom, so it cannot produce a wrapped or NA value.- ...
Additional arguments (unused).
Value
An R array (or vector for shape integer()).