Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

Commit

Permalink
Remove ggml::Tensor::set_data
Browse files Browse the repository at this point in the history
  • Loading branch information
iacore committed Apr 7, 2023
1 parent eab7235 commit 32925e7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
22 changes: 11 additions & 11 deletions ggml/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,17 +361,17 @@ impl Tensor {
})
}

/// Set the tensor's data pointer (useful for mmap-ed data)
///
/// # Safety
///
/// The memory region from `data_ptr` to `data_ptr.offset(tensor.nbytes())` will be read from.
pub unsafe fn set_data(&self, data_ptr: *mut c_void) {
self.with_alive_ctx(|| {
// SAFETY: The with_alive_call guarantees the context is alive
unsafe { *self.ptr.as_ptr() }.data = data_ptr;
})
}
// /// Set the tensor's data pointer (useful for mmap-ed data)
// ///
// /// # Safety
// ///
// /// The memory region from `data_ptr` to `data_ptr.offset(tensor.nbytes())` will be read from.
// pub unsafe fn set_data(&self, data_ptr: *mut c_void) {
// self.with_alive_ctx(|| {
// // SAFETY: The with_alive_call guarantees the context is alive
// unsafe { *self.ptr.as_ptr() }.data = data_ptr;
// })
// }

/// Number of elements in this tensor.
pub fn nelements(&self) -> usize {
Expand Down
3 changes: 1 addition & 2 deletions llama-rs/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ pub(crate) fn load_weights_ggmf_or_unversioned(
byte_size: total_size,
tensor_count: n_tensors.try_into()?,
});
};
}
Ok(())
}

Expand Down Expand Up @@ -264,7 +264,6 @@ fn load_tensor_header_ggmf<'a>(
}

fn tensor_type_size(ftype: i32, ne: [i64; 2]) -> Option<usize> {

match ftype {
0 => Some(ggml::type_size(ggml::Type::F32)),
1 => Some(ggml::type_size(ggml::Type::F16)),
Expand Down

0 comments on commit 32925e7

Please sign in to comment.