pub struct Observer { /* private fields */ }Expand description
Observer for tracking tensor statistics during calibration
Implementations§
Source§impl Observer
impl Observer
Sourcepub fn new(observer_type: ObserverType) -> Self
pub fn new(observer_type: ObserverType) -> Self
Create a new observer
Sourcepub fn new_histogram(num_bins: usize) -> Self
pub fn new_histogram(num_bins: usize) -> Self
Create a new histogram observer with specified number of bins
Sourcepub fn new_percentile(percentile: f32) -> Self
pub fn new_percentile(percentile: f32) -> Self
Create a new percentile observer with specified percentile
Sourcepub fn update(&mut self, tensor: &Tensor) -> TorshResult<()>
pub fn update(&mut self, tensor: &Tensor) -> TorshResult<()>
Update observer with new tensor (optimized with parallel processing)
Sourcepub fn calculate_qparams(&self, dtype: DType) -> TorshResult<(f32, i32)>
pub fn calculate_qparams(&self, dtype: DType) -> TorshResult<(f32, i32)>
Calculate quantization parameters from observed statistics
Sourcepub fn detect_outliers(&self, data: &[f32], factor: f32) -> (Vec<f32>, usize)
pub fn detect_outliers(&self, data: &[f32], factor: f32) -> (Vec<f32>, usize)
Detect and remove outliers using IQR method
Sourcepub fn get_statistics(&self) -> HashMap<String, f32>
pub fn get_statistics(&self) -> HashMap<String, f32>
Get comprehensive statistics from the observer
Sourcepub fn observer_type(&self) -> ObserverType
pub fn observer_type(&self) -> ObserverType
Get the observer type
Sourcepub fn get_min_max(&self) -> (f32, f32)
pub fn get_min_max(&self) -> (f32, f32)
Get the current min/max values
Sourcepub fn num_batches(&self) -> usize
pub fn num_batches(&self) -> usize
Get number of processed batches
Source§impl Observer
Factory functions for creating observers
impl Observer
Factory functions for creating observers
Sourcepub fn moving_average() -> Self
pub fn moving_average() -> Self
Create a MovingAverage observer
Sourcepub fn histogram_with_bins(num_bins: usize) -> Self
pub fn histogram_with_bins(num_bins: usize) -> Self
Create a Histogram observer with custom number of bins
Sourcepub fn percentile() -> Self
pub fn percentile() -> Self
Create a Percentile observer with default percentile
Sourcepub fn percentile_with_value(percentile: f32) -> Self
pub fn percentile_with_value(percentile: f32) -> Self
Create a Percentile observer with custom percentile
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Observer
impl RefUnwindSafe for Observer
impl Send for Observer
impl Sync for Observer
impl Unpin for Observer
impl UnsafeUnpin for Observer
impl UnwindSafe for Observer
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> 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