- Notifications
You must be signed in to change notification settings - Fork5
Safetensors File Format
License
Unknown, MIT licenses found
Licenses found
Unknown
LICENSEMIT
LICENSE.mdNotificationsYou must be signed in to change notification settings
mlverse/safetensors
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
safetensors is a pure R implementation of thesafetensors file formatfor both reading and writing. It currently supports the {torch} and{pjrt} frameworks.
safetensors can be installed from CRAN with:
install.packages("safetensors")The development version of safetensors fromGitHub with:
# install.packages("devtools")devtools::install_github("mlverse/safetensors")
Here’s an example of writing and reading safetensors files incombination with torch:
library(torch)library(safetensors)tensors<-list(x= torch_randn(10,10),y= torch_ones(10,10))str(tensors)#> List of 2#> $ x:Float [1:10, 1:10]#> $ y:Float [1:10, 1:10]tmp<- tempfile()safe_save_file(tensors,tmp)tensors<- safe_load_file(tmp,framework="torch")str(tensors)#> List of 2#> $ x:Float [1:10, 1:10]#> $ y:Float [1:10, 1:10]#> - attr(*, "metadata")=List of 2#> ..$ x:List of 3#> .. ..$ shape : int [1:2] 10 10#> .. ..$ dtype : chr "F32"#> .. ..$ data_offsets: int [1:2] 0 400#> ..$ y:List of 3#> .. ..$ shape : int [1:2] 10 10#> .. ..$ dtype : chr "F32"#> .. ..$ data_offsets: int [1:2] 400 800#> - attr(*, "max_offset")= int 929
About
Safetensors File Format
Resources
License
Unknown, MIT licenses found
Licenses found
Unknown
LICENSEMIT
LICENSE.mdUh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.
Contributors3
Uh oh!
There was an error while loading.Please reload this page.