pub struct CheckpointTensor {
pub name: String,
pub shape: Vec<u64>,
pub data: Vec<f32>,
}Expand description
A single tensor entry in the checkpoint.
Fields§
§name: StringUnique tensor name within the checkpoint (e.g. "layer.0.weight").
shape: Vec<u64>N-dimensional shape; product must equal data.len().
data: Vec<f32>Raw f32 data in row-major order.
Implementations§
Source§impl CheckpointTensor
impl CheckpointTensor
Sourcepub fn new(name: impl Into<String>, data: Vec<f32>, shape: Vec<u64>) -> Self
pub fn new(name: impl Into<String>, data: Vec<f32>, shape: Vec<u64>) -> Self
Construct a checkpoint tensor.
Sourcepub fn element_count(&self) -> u64
pub fn element_count(&self) -> u64
Total number of scalar elements: product of all shape dimensions.
Sourcepub fn size_bytes(&self) -> usize
pub fn size_bytes(&self) -> usize
Size of the tensor data in bytes (element_count * 4).
Sourcepub fn from_weight_tensor(wt: &WeightTensor) -> Self
pub fn from_weight_tensor(wt: &WeightTensor) -> Self
Convert from a crate::model_merge::WeightTensor.
The usize shape dimensions are widened to u64.
Sourcepub fn to_weight_tensor(&self) -> WeightTensor
pub fn to_weight_tensor(&self) -> WeightTensor
Convert back to a crate::model_merge::WeightTensor.
The u64 shape dimensions are narrowed to usize; values that do not
fit in usize are clamped to usize::MAX (a safeguard — real models
never have dimensions that large).
Trait Implementations§
Source§impl Clone for CheckpointTensor
impl Clone for CheckpointTensor
Source§fn clone(&self) -> CheckpointTensor
fn clone(&self) -> CheckpointTensor
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for CheckpointTensor
impl RefUnwindSafe for CheckpointTensor
impl Send for CheckpointTensor
impl Sync for CheckpointTensor
impl Unpin for CheckpointTensor
impl UnsafeUnpin for CheckpointTensor
impl UnwindSafe for CheckpointTensor
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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