pub struct DeviceMemSchema {
pub model_num_nodes: usize,
pub by_partition: Vec<Partition>,
pub by_steps: Vec<Vec<Option<NodeMemReq>>>,
}Expand description
This struct represent a memory schema for node output memory that are handled by a GPU.
Fields§
§model_num_nodes: usizeTotal numbef in the model.
by_partition: Vec<Partition>§by_steps: Vec<Vec<Option<NodeMemReq>>>Implementations§
Source§impl DeviceMemSchema
impl DeviceMemSchema
Sourcepub fn size_by_partition(&self) -> Vec<TDim>
pub fn size_by_partition(&self) -> Vec<TDim>
Returns memory size of each inner partitions.
Sourcepub fn eval_size_by_partition(
&self,
symbols: &SymbolValues,
) -> TractResult<Vec<i64>>
pub fn eval_size_by_partition( &self, symbols: &SymbolValues, ) -> TractResult<Vec<i64>>
Evaluate memory size by partition for given symbol values.
Sourcepub fn memory_size(&self) -> TDim
pub fn memory_size(&self) -> TDim
Returns total memory size required for the schema.
Sourcepub fn eval_memory_size(&self, symbols: &SymbolValues) -> TractResult<i64>
pub fn eval_memory_size(&self, symbols: &SymbolValues) -> TractResult<i64>
Evaluate memory size required for the schema for given symbol values.
Sourcepub fn compute_offset_by_node(
&self,
symbols: &SymbolValues,
) -> TractResult<Vec<Option<usize>>>
pub fn compute_offset_by_node( &self, symbols: &SymbolValues, ) -> TractResult<Vec<Option<usize>>>
Compute offsets for each node for given symbols. Node ids are indexes in the returned vector.
Sourcepub fn eval_peak_memory_size(&self, symbols: &SymbolValues) -> TractResult<i64>
pub fn eval_peak_memory_size(&self, symbols: &SymbolValues) -> TractResult<i64>
Evaluate peak memory size for given symbols. The return value is lower or equal to the memory size of the schema. The difference between peak memory size and memory size represents the memory fragmentation introduced by the schema.
Sourcepub fn eval_usage(&self, symbols: &SymbolValues) -> TractResult<f32>
pub fn eval_usage(&self, symbols: &SymbolValues) -> TractResult<f32>
Evaluate the usage for given symbols as the ratio between schema memory size and peak memory size. A value of 1.0 means that the schema doesn’t introduce memory fragmentation.
Source§impl DeviceMemSchema
impl DeviceMemSchema
Sourcepub fn resolve(
&self,
symbols: &SymbolValues,
) -> TractResult<DeviceResolvedMemSchema>
pub fn resolve( &self, symbols: &SymbolValues, ) -> TractResult<DeviceResolvedMemSchema>
Resolve Memory schema with given symbols.
Sourcepub fn build(
model: &TypedModel,
order: &[usize],
hint: &SymbolValues,
) -> TractResult<DeviceMemSchema>
pub fn build( model: &TypedModel, order: &[usize], hint: &SymbolValues, ) -> TractResult<DeviceMemSchema>
Build a memory schema for given model and execution order. The hint is used to optimize the memory schema because it is based on symbolic dimensions. That doesn’t mean it will be optimal for all possible values for symbolic dimensions.
Trait Implementations§
Source§impl Clone for DeviceMemSchema
impl Clone for DeviceMemSchema
Source§fn clone(&self) -> DeviceMemSchema
fn clone(&self) -> DeviceMemSchema
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DeviceMemSchema
impl Debug for DeviceMemSchema
Source§impl Display for DeviceMemSchema
impl Display for DeviceMemSchema
Source§impl Hash for DeviceMemSchema
impl Hash for DeviceMemSchema
Source§impl PartialEq for DeviceMemSchema
impl PartialEq for DeviceMemSchema
impl Eq for DeviceMemSchema
impl StructuralPartialEq for DeviceMemSchema
Auto Trait Implementations§
impl Freeze for DeviceMemSchema
impl !RefUnwindSafe for DeviceMemSchema
impl Send for DeviceMemSchema
impl Sync for DeviceMemSchema
impl Unpin for DeviceMemSchema
impl UnsafeUnpin for DeviceMemSchema
impl !UnwindSafe for DeviceMemSchema
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
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>. Box<dyn Any> can
then be further downcast into Box<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>. Rc<Any> 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> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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