safe_load_file {safetensors}R Documentation

Safe load a safetensors file

Description

Loads an safetensors file from disk.

Usage

safe_load_file(path, ..., framework = "torch", device = "cpu")

Arguments

path

Path to the file to load

...

Unused

framework

Framework to load the data into. Currently only torch is supported

device

Device to copy data once loaded

Value

A list with tensors in the file. The metadata attribute can be used to find metadata the metadata header in the file.

See Also

safetensors, safe_save_file()

Examples

if (rlang::is_installed("torch") && torch::torch_is_installed()) {
  tensors <- list(x = torch::torch_randn(10, 10))
  temp <- tempfile()
  safe_save_file(tensors, temp)
  safe_load_file(temp)
}


[Package safetensors version 0.1.2 Index]