save

Function save 

Source
pub fn save<B: Backend>(
    path: impl AsRef<Path>,
    tensors: &[(String, Tensor<B>)],
) -> Result<()>
Expand description

Save named tensors to a .safetensors file.

use shrew::safetensors;
use shrew::prelude::*;

let w = Tensor::<CpuBackend>::zeros((2, 3), DType::F32, &CpuDevice).unwrap();
let tensors = vec![("weight".to_string(), w)];
safetensors::save("model.safetensors", &tensors).unwrap();