
CPU fallback methods for dplyr verbs without a GPU-native implementation
Source:R/fallback.R
fallback-verbs.Rdcuplyr implements every dplyr generic on tbl_gpu, but not every one of
them runs natively on the GPU. The methods documented here provide a
transparent CPU fallback: they materialize any pending lazy operations,
collect() .data to a tibble (restoring group_by() structure from
.data's grouping so grouped semantics apply exactly as on a real
grouped_df), run the real dplyr verb on the CPU, and re-upload the
result via tbl_gpu() – restoring grouping (read back from the verb's
actual result, since some verbs change it), execution mode (lazy stays
lazy), and factor levels.
Usage
# S3 method for class 'tbl_gpu'
do(.data, ...)
# S3 method for class 'tbl_gpu'
nest_join(
x,
y,
by = NULL,
copy = FALSE,
keep = NULL,
name = NULL,
...,
na_matches = c("na", "never"),
unmatched = "drop"
)
# S3 method for class 'tbl_gpu'
group_map(.data, .f, ..., .keep = FALSE)
# S3 method for class 'tbl_gpu'
group_modify(.data, .f, ..., .keep = FALSE)
# S3 method for class 'tbl_gpu'
group_nest(.tbl, ..., .key = "data", keep = FALSE)
# S3 method for class 'tbl_gpu'
nest_by(.data, ..., .key = "data", .keep = FALSE)Details
Verbs whose result isn't a data frame at all (e.g. dplyr::group_map()'s
list), or whose result is a data frame
containing list-columns with no GPU representation (e.g.
dplyr::nest_by(), dplyr::group_nest(), dplyr::nest_join()'s nested
match column), are returned as plain R objects rather than re-uploaded.
A GPU key match for nest_join()/group_nest()/nest_by() was measured and
does not pay (the time is building the nested tibbles on the host), so they
stay CPU fallbacks.
Every fallback calls cuplyr_fallback_notify(), so
options(cuplyr.fallback = "warn") (or "error") can be used to surface
(or forbid) accidental fallbacks in code that's expected to stay fully
GPU-native. The notice names the verb, the expression, the reason and the
size collected; see cuplyr-fallback.