The core CPU fallback primitive. Materializes any pending lazy
operations, collects .data to a tibble (restoring group_by() structure
from .data$groups so grouped semantics apply on the CPU exactly as they
would on a real grouped_df; a rowwise table becomes dplyr's rowwise_df
of its rowwise vars), applies expr_fn (which should call the
real dplyr verb), and re-uploads the result via tbl_gpu() (a rowwise_df
result goes back up as a rowwise table).
Usage
gpu_fallback(
verb_name,
.data,
expr_fn,
...,
as_is = FALSE,
detail = NULL,
reason = detail,
expr = NA_character_,
also = NULL
)Arguments
- verb_name
Character, the verb name to use in the fallback notification (e.g.
"transmute","slice_min"), gated byoptions(cuplyr.fallback = )(seecuplyr_fallback_notify()).- .data
A
tbl_gpuobject.- expr_fn
A function of one argument (a tibble, already grouped if
.datawas grouped) that calls the corresponding real dplyr verb and returns its result.- as_is
Logical. If
TRUE,expr_fn's return value is always returned unchanged, never re-uploaded – for a verb that returns metadata about the grouping/data rather than a transformed dataset, even when that metadata happens to be a small data frame (dplyr's own grouping-metadata queries, e.g.group_data()/group_keys(), are GPU-native and don't use it; the parameter is for any fallback verb with the same "always a plain R object" shape).- detail
Older spelling of
reason.- reason
Text saying why the call runs on the CPU: the
reasonof the notice (cuplyr_fallback_notify(), cuplyr-fallback). Every caller gives one; a reason made byfallback_failed_reason()orshadow_screen_text()carries the offending expression as its"expr"attribute. On a rowwise table it is prefixed with "rowwise table: " (rowwise_rerun()passes the reason its native attempt recorded).- expr
The offending expression as text, when the whole call is not at fault (
NA: the call as a whole goes).- also
A second
tbl_gpu(theyof a join, set operation orrows_*(); or a list of them) the fallback collects too: its size is added to the notice. It must not have pending operations (compute it first).
Value
Either a new tbl_gpu (grouping, execution mode, and factor
levels restored/round-tripped), or expr_fn's raw return value
unchanged when: as_is = TRUE; the result isn't a data frame at all
(e.g. group_map()'s list); or the result is a
data frame that contains list-columns (e.g. nest_by()/group_nest()/
nest_join()'s nested-tibble columns), which have no GPU representation.
When the result is a grouped data frame whose group_data() keeps groups
with no row that a plain regroup of its data would not have (dplyr's
dplyr_col_modify.grouped_df() does this for a verb that leaves the group
columns alone, after filter()/slice() with .preserve = TRUE), the
returned tbl_gpu carries those keys as $fixed_keys (see
fixed_keys_of()); verbs that regroup get none.
Details
The lazy result of a lazy .data carries the step's history as its origin
field (fallback_record_origin()), which explain() and show_query() print.
