.r_to_torch {mafR}R Documentation

Utility to manage torch tensors

Description

(Currently not used nor exported) utility converting an R object to a torch tensor.

Usage

  .r_to_torch(x, py_handle, device) 

Arguments

x

An R object suitable for use in reticulate::r_to_py(x) (this being as indefinite as the r_to_py documentation in this respect.)

py_handle

The return value of get_py_MAF_handle, or possibly more generally an environment with (at least) elements torch and device defined as in such a return value.

device

Character: "cpu"; or a GPU backend, either "cuda" (or "cuda:0", etc.) or "mps" depending on system capabilities.

Value

r_to_torch returns a 32-bit floating-point torch tensor allocated on the given device.

Examples

my_env <- list2env(list(is_set=FALSE),parent = emptyenv())
my_env <- get_py_MAF_handle(my_env, reset=FALSE, torch_device="cpu")

[Package mafR version 1.1.6 Index]