pub struct CalibrationDataset {
pub samples: Vec<Vec<f32>>,
pub shape: Vec<usize>,
}Expand description
A collection of FP32 calibration samples used for range estimation.
Fields§
§samples: Vec<Vec<f32>>Individual samples, each flattened to match shape.
shape: Vec<usize>Shape of a single sample (excluding batch dimension).
Implementations§
Source§impl CalibrationDataset
impl CalibrationDataset
Sourcepub fn from_numpy(path: impl AsRef<Path>) -> Result<Self>
pub fn from_numpy(path: impl AsRef<Path>) -> Result<Self>
Load calibration samples from a NumPy .npy file.
The array must be at least 2-dimensional [batch, ...].
Requires the calibration feature (enabled by default).
§Errors
Returns QuantizeError::Calibration if the file is missing, not .npy,
or has an invalid shape.
Sourcepub fn random(
shape: Vec<usize>,
num_samples: usize,
range: (f32, f32),
) -> Result<Self>
pub fn random( shape: Vec<usize>, num_samples: usize, range: (f32, f32), ) -> Result<Self>
Generate random calibration samples uniformly distributed in range.
§Errors
Returns QuantizeError::Calibration if shape is empty, num_samples is 0,
or the range is invalid.
Sourcepub fn from_samples(samples: Vec<Vec<f32>>, shape: Vec<usize>) -> Result<Self>
pub fn from_samples(samples: Vec<Vec<f32>>, shape: Vec<usize>) -> Result<Self>
Create a dataset from pre-existing sample vectors.
§Errors
Returns QuantizeError::Calibration if samples is empty or any
sample has the wrong length for the given shape.
Sourcepub fn sample_shape(&self) -> &[usize]
pub fn sample_shape(&self) -> &[usize]
Shape of a single sample (excluding batch dimension).
Trait Implementations§
Source§impl Clone for CalibrationDataset
impl Clone for CalibrationDataset
Source§fn clone(&self) -> CalibrationDataset
fn clone(&self) -> CalibrationDataset
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for CalibrationDataset
impl RefUnwindSafe for CalibrationDataset
impl Send for CalibrationDataset
impl Sync for CalibrationDataset
impl Unpin for CalibrationDataset
impl UnsafeUnpin for CalibrationDataset
impl UnwindSafe for CalibrationDataset
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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>
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>
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