pub struct DataParallelTrainer { /* private fields */ }Expand description
Data parallel trainer
Implementations§
Source§impl DataParallelTrainer
impl DataParallelTrainer
pub fn new(config: DistributedConfig) -> Self
Sourcepub fn split_data(&self, data: &Tensor, labels: &Tensor) -> (Tensor, Tensor)
pub fn split_data(&self, data: &Tensor, labels: &Tensor) -> (Tensor, Tensor)
Split data across workers
Sourcepub fn accumulate_gradients(&mut self, gradients: Vec<Vec<f32>>)
pub fn accumulate_gradients(&mut self, gradients: Vec<Vec<f32>>)
Accumulate local gradients
Sourcepub fn sync_gradients(&mut self) -> Vec<Vec<f32>>
pub fn sync_gradients(&mut self) -> Vec<Vec<f32>>
Synchronize gradients across workers
Sourcepub fn all_reduce(&self, gradients: &[Vec<f32>]) -> Vec<Vec<f32>>
pub fn all_reduce(&self, gradients: &[Vec<f32>]) -> Vec<Vec<f32>>
All-reduce operation for gradients
Sourcepub fn broadcast_parameters(&self, parameters: &[Vec<f32>]) -> Vec<Vec<f32>>
pub fn broadcast_parameters(&self, parameters: &[Vec<f32>]) -> Vec<Vec<f32>>
Broadcast parameters from rank 0 to all workers
pub fn is_master(&self) -> bool
Auto Trait Implementations§
impl Freeze for DataParallelTrainer
impl RefUnwindSafe for DataParallelTrainer
impl Send for DataParallelTrainer
impl Sync for DataParallelTrainer
impl Unpin for DataParallelTrainer
impl UnwindSafe for DataParallelTrainer
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