Returns the target platform currently set by an enclosing stablehlo()
call (e.g. "cpu", "cuda"). Platform-aware lowering rules call this to
branch on the target — e.g. SVD switches to a layout-flip variant when
targeting CUDA with m < n because cuSOLVER's gesvd requires m >= n.
Returns NULL outside of a lowering call.
local_platform() sets the current platform for the duration of the
calling scope, restoring the previous value via withr::defer() when the
scope exits. Useful in tests and for manually exercising platform-aware
lowering rules outside of a stablehlo() call.
Usage
current_platform()
local_platform(platform, envir = parent.frame())Value
current_platform() returns NULL or character(1).
local_platform() invisibly returns the previous platform.