safe_load_file: Safe load a safetensors file

View source: R/safetensors.R

safe_load_fileR Documentation

Safe load a safetensors file

Description

Loads an safetensors file from disk.

Usage

safe_load_file(path, ..., framework)

Arguments

path

Path to the file to load

...

Additional framework dependent arguments to pass to the tensor creation function.

framework

Framework to load the data into. Currently supports "torch" and "pjrt"

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, framework = "torch")
}


safetensors documentation built on Aug. 18, 2025, 5:29 p.m.