Skip to contents

Saves a named list of tensors to a file in the safetensors format.

Usage

nv_save(tensors, path)

Arguments

tensors

(named list of AnvilTensor)
Named list of tensors to save. Names must be unique.

path

(character(1))
File path to write to.

Value

NULL (invisibly).

Details

This is a convenience wrapper around nv_serialize() that opens and closes a file connection.

Examples

x <- nv_tensor(array(1:6, dim = c(2, 3)))
x
#> AnvilTensor
#>  1 3 5
#>  2 4 6
#> [ CPUi32{2,3} ] 
path <- tempfile(fileext = ".safetensors")
nv_save(list(x = x), path)
nv_read(path)
#> $x
#> AnvilTensor
#>  1 3 5
#>  2 4 6
#> [ CPUi32{2,3} ] 
#>