pub struct DataParallel { /* private fields */ }Expand description
Data Parallel model wrapper for single-node multi-GPU training
Implementations§
Source§impl DataParallel
impl DataParallel
Sourcepub fn new(
model: Box<dyn Model<f32>>,
devices: Vec<Device>,
comm_runtime: Arc<RwLock<CommunicationRuntime>>,
) -> Result<Self>
pub fn new( model: Box<dyn Model<f32>>, devices: Vec<Device>, comm_runtime: Arc<RwLock<CommunicationRuntime>>, ) -> Result<Self>
Create new DataParallel model wrapper
Sourcepub fn forward_parallel(
&self,
inputs: &[Tensor<f32>],
) -> Result<Vec<Tensor<f32>>>
pub fn forward_parallel( &self, inputs: &[Tensor<f32>], ) -> Result<Vec<Tensor<f32>>>
Perform forward pass with data parallelism
Sourcepub fn sync_gradients(&mut self) -> Result<()>
pub fn sync_gradients(&mut self) -> Result<()>
Synchronize gradients across all device replicas
Sourcepub fn set_sync_mode(&mut self, mode: SynchronizationMode)
pub fn set_sync_mode(&mut self, mode: SynchronizationMode)
Set synchronization mode
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DataParallel
impl !RefUnwindSafe for DataParallel
impl !Send for DataParallel
impl !Sync for DataParallel
impl Unpin for DataParallel
impl UnsafeUnpin for DataParallel
impl !UnwindSafe for DataParallel
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> 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