feat: save safetensors to the database
Some checks failed
build / checks-matrix (push) Successful in 19m23s
build / codecov (push) Failing after 19m26s
docs / docs (push) Failing after 28m47s
build / checks-build (push) Has been cancelled

This commit is contained in:
uttarayan21
2025-08-20 12:14:08 +05:30
parent 37adb74adf
commit 97f64e7e10
6 changed files with 108 additions and 63 deletions

View File

@@ -68,17 +68,17 @@ use safetensors::tensor::SafeTensors;
/// let view = SafeArrayView::from_bytes(&bytes).unwrap();
/// let tensor: ndarray::ArrayView2<f32> = view.tensor("data").unwrap();
/// ```
pub struct SafeArrayView<'a> {
pub struct SafeArraysView<'a> {
pub tensors: SafeTensors<'a>,
}
impl<'a> SafeArrayView<'a> {
impl<'a> SafeArraysView<'a> {
fn new(tensors: SafeTensors<'a>) -> Self {
Self { tensors }
}
/// Create a SafeArrayView from serialized bytes
pub fn from_bytes(bytes: &'a [u8]) -> Result<SafeArrayView<'a>> {
pub fn from_bytes(bytes: &'a [u8]) -> Result<SafeArraysView<'a>> {
let tensors = SafeTensors::deserialize(bytes)?;
Ok(Self::new(tensors))
}
@@ -413,7 +413,7 @@ fn test_serialize_safe_arrays() {
assert!(!serialized.is_empty());
// Deserialize to check if it works
let deserialized = SafeArrayView::from_bytes(&serialized).unwrap();
let deserialized = SafeArraysView::from_bytes(&serialized).unwrap();
assert_eq!(deserialized.len(), 2);
assert_eq!(
deserialized