ag_local_mode: Set ag_* GPU modes for the rest of the calling function

View source: R/ag_defer.R

ag_local_modeR Documentation

Set ag_* GPU modes for the rest of the calling function

Description

Sets graph mode (ag_graph_mode) and/or matrix-multiply precision (ag_matmul_precision) and restores the previous values when the calling function exits – normally or by an error. One place for both, instead of a pair of on.exit calls per setting.

Usage

ag_local_mode(graph = NULL, matmul_precision = NULL, envir = parent.frame())

Arguments

graph

TRUE/FALSE, or NULL to leave it.

matmul_precision

"default"/"f32", or NULL to leave it.

envir

The frame whose exit restores the settings (the caller's).

Value

The previous values, invisibly.

Examples

f <- function() {
  ag_local_mode(graph = TRUE, matmul_precision = "f32")
  c(ag_graph_mode(), ag_matmul_precision())
}
f()                      # TRUE "f32"
ag_graph_mode()          # back to the previous value

ggmlR documentation built on Oct. 23, 2026, 1:07 a.m.