Converts a base R matrix to a torch tensor on the resolved backend device
and dtype (getBackendDevice/getBackendDtype) if
an accelerator is available and requested; otherwise returns mat
unchanged (already a tensor, or backend = "cpu", or no accelerator
present). Exposed so downstream packages (e.g. spiDE) share the exact same
device/dtype resolution SpaNorm's own fitting uses.
Usage
toGPUMatrix(mat, ..., backend = c("auto", "cpu", "gpu"))Examples
toGPUMatrix(matrix(1:4, 2, 2), backend = "cpu")
#> [,1] [,2]
#> [1,] 1 3
#> [2,] 2 4