pub struct TransformerMemoryManager<T: Float + Debug + ScalarOperand + Send + Sync + 'static> { /* private fields */ }Expand description
Transformer memory manager
Implementations§
Source§impl<T: Float + Debug + ScalarOperand + Send + Sync + 'static> TransformerMemoryManager<T>
impl<T: Float + Debug + ScalarOperand + Send + Sync + 'static> TransformerMemoryManager<T>
Sourcepub fn new(config: &TransformerBasedOptimizerConfig<T>) -> Result<Self>
pub fn new(config: &TransformerBasedOptimizerConfig<T>) -> Result<Self>
Create new memory manager
Sourcepub fn store(&mut self, key: String, tensor: Array2<T>) -> Result<()>
pub fn store(&mut self, key: String, tensor: Array2<T>) -> Result<()>
Store tensor in memory with key
Store tensor under key.
§Errors
Returns Err when the tensor’s feature width differs from the model
dimension this manager was built for. The manager records the dimension
at construction but never checked it, so a caller could fill the cache
with tensors the transformer cannot consume and only find out at the
point of use.
Sourcepub fn get_memory_usage(&self) -> usize
pub fn get_memory_usage(&self) -> usize
Get memory usage statistics
Sourcepub fn optimize_memory(&mut self) -> Result<OptimizationReport>
pub fn optimize_memory(&mut self) -> Result<OptimizationReport>
Optimize memory layout
Sourcepub fn prefetch(&mut self, keys: Vec<String>) -> Result<usize>
pub fn prefetch(&mut self, keys: Vec<String>) -> Result<usize>
Prefetch data based on access patterns
Sourcepub fn get_statistics(&self) -> &MemoryStatistics
pub fn get_statistics(&self) -> &MemoryStatistics
Get memory statistics
Sourcepub fn get_access_patterns(&self) -> AccessPatterns
pub fn get_access_patterns(&self) -> AccessPatterns
Get access patterns
Sourcepub fn set_strategy(&mut self, strategy: MemoryManagementStrategy)
pub fn set_strategy(&mut self, strategy: MemoryManagementStrategy)
Set memory management strategy
Sourcepub fn get_memory_pressure(&self) -> f64
pub fn get_memory_pressure(&self) -> f64
Get current memory pressure
Auto Trait Implementations§
impl<T> Freeze for TransformerMemoryManager<T>where
MemoryCache<T>: Freeze,
Option<MemoryCache<T>>: Freeze,
Option<CompressionManager<T>>: Freeze,
impl<T> RefUnwindSafe for TransformerMemoryManager<T>where
MemoryCache<T>: RefUnwindSafe,
Option<MemoryCache<T>>: RefUnwindSafe,
Option<CompressionManager<T>>: RefUnwindSafe,
impl<T> Send for TransformerMemoryManager<T>
impl<T> Sync for TransformerMemoryManager<T>
impl<T> Unpin for TransformerMemoryManager<T>
impl<T> UnsafeUnpin for TransformerMemoryManager<T>where
MemoryCache<T>: UnsafeUnpin,
Option<MemoryCache<T>>: UnsafeUnpin,
Option<CompressionManager<T>>: UnsafeUnpin,
impl<T> UnwindSafe for TransformerMemoryManager<T>where
MemoryCache<T>: UnwindSafe,
Option<MemoryCache<T>>: UnwindSafe,
Option<CompressionManager<T>>: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.