pub struct ShardIndex { /* private fields */ }Expand description
Parsed shard index from HuggingFace format.
Represents the model.safetensors.index.json file structure:
{
"metadata": {...},
"weight_map": {
"layer.0.weight": "model-00001-of-00006.safetensors",
"layer.1.weight": "model-00002-of-00006.safetensors"
}
}Implementations§
Source§impl ShardIndex
impl ShardIndex
Sourcepub fn add_mapping(&mut self, tensor_name: &str, shard_file: &str)
pub fn add_mapping(&mut self, tensor_name: &str, shard_file: &str)
Add tensor to shard mapping
Sourcepub fn shard_for_tensor(&self, tensor_name: &str) -> Option<&str>
pub fn shard_for_tensor(&self, tensor_name: &str) -> Option<&str>
Get shard file for a tensor
Sourcepub fn shard_index(&self, shard_file: &str) -> Option<usize>
pub fn shard_index(&self, shard_file: &str) -> Option<usize>
Get shard index (0-based) for a shard file
Sourcepub fn shard_count(&self) -> usize
pub fn shard_count(&self) -> usize
Get total number of shards
Sourcepub fn tensor_count(&self) -> usize
pub fn tensor_count(&self) -> usize
Get total number of tensors
Sourcepub fn shard_files(&self) -> &[String]
pub fn shard_files(&self) -> &[String]
Get all shard filenames in order
Sourcepub fn tensor_names(&self) -> Vec<&str>
pub fn tensor_names(&self) -> Vec<&str>
Get all tensor names (sorted for consistent processing)
Sourcepub fn tensors_by_shard(&self) -> HashMap<&str, Vec<&str>>
pub fn tensors_by_shard(&self) -> HashMap<&str, Vec<&str>>
Group tensors by shard for efficient loading
Sourcepub fn set_metadata(&mut self, key: &str, value: &str)
pub fn set_metadata(&mut self, key: &str, value: &str)
Set metadata
Sourcepub fn get_metadata(&self, key: &str) -> Option<&str>
pub fn get_metadata(&self, key: &str) -> Option<&str>
Get metadata
Trait Implementations§
Source§impl Clone for ShardIndex
impl Clone for ShardIndex
Source§fn clone(&self) -> ShardIndex
fn clone(&self) -> ShardIndex
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ShardIndex
impl Debug for ShardIndex
Source§impl Default for ShardIndex
impl Default for ShardIndex
Source§fn default() -> ShardIndex
fn default() -> ShardIndex
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ShardIndex
impl RefUnwindSafe for ShardIndex
impl Send for ShardIndex
impl Sync for ShardIndex
impl Unpin for ShardIndex
impl UnsafeUnpin for ShardIndex
impl UnwindSafe for ShardIndex
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more