pub struct LayerPlacement {
pub input: Device,
pub hidden: Vec<Device>,
pub output: Device,
}Expand description
Where each layer of a LayerParallelism model runs: the device of
its input layer, of each hidden layer, and of its output layer.
Fields§
§input: DeviceWhere the input layer runs.
Where each hidden layer runs, in forward order.
output: DeviceWhere the output layer runs.
Implementations§
Source§impl LayerPlacement
impl LayerPlacement
Sourcepub fn new(stages: &[LayerStage]) -> Self
pub fn new(stages: &[LayerStage]) -> Self
One device per hidden layer, read off the stages in order. The input layer runs on the first stage’s device and the output layer on the last stage’s, so a stage of no hidden layers gives one of them a device to itself.
§Panics
Panics when stages is empty.
Sourcepub fn devices(&self) -> Vec<Device>
pub fn devices(&self) -> Vec<Device>
Every device a layer runs on, each once, in forward order: the input layer’s first.
Sourcepub fn stages(&self) -> Vec<LayerStage>
pub fn stages(&self) -> Vec<LayerStage>
Each device’s run of consecutive hidden layers, in forward order.
Sourcepub fn even(devices: &[Device], num_hidden_layers: usize) -> Self
pub fn even(devices: &[Device], num_hidden_layers: usize) -> Self
The hidden layers shared out in order across devices, as evenly as the count allows:
when it does not divide, the first devices take one layer more. Devices past the layer
count are left out rather than given a stage with nothing to run; new places
those on purpose.
§Panics
Panics when devices is empty.
Sourcepub fn by_memory(devices: &[DeviceMemory], memory: &LayerMemory) -> Option<Self>
pub fn by_memory(devices: &[DeviceMemory], memory: &LayerMemory) -> Option<Self>
The layers in order across devices, in runs sized to each device’s capacity: the device
using the largest share of its capacity uses as small a share as a split in order allows,
so every device keeps about the same fraction free. A layer too large for what a device has
left moves on to the next, and devices past the last run are left out.
None when the layers do not fit on devices at all.
Trait Implementations§
Source§impl Clone for LayerPlacement
impl Clone for LayerPlacement
Source§impl Debug for LayerPlacement
impl Debug for LayerPlacement
Source§impl PartialEq for LayerPlacement
impl PartialEq for LayerPlacement
impl StructuralPartialEq for LayerPlacement
Auto Trait Implementations§
impl Freeze for LayerPlacement
impl RefUnwindSafe for LayerPlacement
impl Send for LayerPlacement
impl Sync for LayerPlacement
impl Unpin for LayerPlacement
impl UnsafeUnpin for LayerPlacement
impl UnwindSafe for LayerPlacement
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneExpand for Twhere
T: Clone,
impl<T> CloneExpand for Twhere
T: Clone,
fn __expand_clone_method(&self, _: &Scope) -> 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>, which can then be
downcast into Box<dyn 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>, which 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> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> ErasedDestructor for Twhere
T: 'static,
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> ⓘ
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