pub struct MemoryProfilerCallback {
pub stats: MemoryStats,
/* private fields */
}Expand description
Memory profiler callback for tracking memory usage during training.
§Example
use tensorlogic_train::{MemoryProfilerCallback, Callback};
let mut profiler = MemoryProfilerCallback::new()
.with_epoch_tracking(true)
.with_batch_tracking(false);
// Use in training loopFields§
§stats: MemoryStatsMemory statistics.
Implementations§
Source§impl MemoryProfilerCallback
impl MemoryProfilerCallback
Sourcepub fn with_epoch_tracking(self, enabled: bool) -> Self
pub fn with_epoch_tracking(self, enabled: bool) -> Self
Enable epoch-level tracking.
Sourcepub fn with_batch_tracking(self, enabled: bool) -> Self
pub fn with_batch_tracking(self, enabled: bool) -> Self
Enable batch-level tracking.
Sourcepub fn with_log_frequency(self, frequency: usize) -> Self
pub fn with_log_frequency(self, frequency: usize) -> Self
Set logging frequency.
Sourcepub fn get_stats(&self) -> &MemoryStats
pub fn get_stats(&self) -> &MemoryStats
Get memory statistics.
Sourcepub fn estimate_tensor_memory(tensors: &[&[f64]]) -> usize
pub fn estimate_tensor_memory(tensors: &[&[f64]]) -> usize
Estimate current memory usage based on tensors.
This is a simplified estimation - actual memory usage depends on allocator behavior, alignment, and fragmentation.
Trait Implementations§
Source§impl Callback for MemoryProfilerCallback
impl Callback for MemoryProfilerCallback
Source§fn on_train_begin(&mut self, _state: &TrainingState) -> TrainResult<()>
fn on_train_begin(&mut self, _state: &TrainingState) -> TrainResult<()>
Called at the beginning of training.
Source§fn on_epoch_begin(
&mut self,
_epoch: usize,
_state: &TrainingState,
) -> TrainResult<()>
fn on_epoch_begin( &mut self, _epoch: usize, _state: &TrainingState, ) -> TrainResult<()>
Called at the beginning of an epoch.
Source§fn on_epoch_end(
&mut self,
epoch: usize,
state: &TrainingState,
) -> TrainResult<()>
fn on_epoch_end( &mut self, epoch: usize, state: &TrainingState, ) -> TrainResult<()>
Called at the end of an epoch.
Source§fn on_batch_end(
&mut self,
batch: usize,
state: &TrainingState,
) -> TrainResult<()>
fn on_batch_end( &mut self, batch: usize, state: &TrainingState, ) -> TrainResult<()>
Called at the end of a batch.
Source§fn on_train_end(&mut self, _state: &TrainingState) -> TrainResult<()>
fn on_train_end(&mut self, _state: &TrainingState) -> TrainResult<()>
Called at the end of training.
Source§fn on_batch_begin(
&mut self,
_batch: usize,
_state: &TrainingState,
) -> TrainResult<()>
fn on_batch_begin( &mut self, _batch: usize, _state: &TrainingState, ) -> TrainResult<()>
Called at the beginning of a batch.
Source§fn on_validation_end(&mut self, _state: &TrainingState) -> TrainResult<()>
fn on_validation_end(&mut self, _state: &TrainingState) -> TrainResult<()>
Called after validation.
Source§fn should_stop(&self) -> bool
fn should_stop(&self) -> bool
Check if training should stop early.
Source§impl Clone for MemoryProfilerCallback
impl Clone for MemoryProfilerCallback
Source§fn clone(&self) -> MemoryProfilerCallback
fn clone(&self) -> MemoryProfilerCallback
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 MemoryProfilerCallback
impl Debug for MemoryProfilerCallback
Auto Trait Implementations§
impl Freeze for MemoryProfilerCallback
impl RefUnwindSafe for MemoryProfilerCallback
impl Send for MemoryProfilerCallback
impl Sync for MemoryProfilerCallback
impl Unpin for MemoryProfilerCallback
impl UnwindSafe for MemoryProfilerCallback
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