pub trait Cache: HasErr {
// Required methods
fn try_enable_cache(&self) -> Result<(), Self::Err>;
fn try_disable_cache(&self) -> Result<(), Self::Err>;
fn try_empty_cache(&self) -> Result<(), Self::Err>;
// Provided methods
fn enable_cache(&self) { ... }
fn disable_cache(&self) { ... }
fn empty_cache(&self) { ... }
}
Required Methods§
sourcefn try_enable_cache(&self) -> Result<(), Self::Err>
fn try_enable_cache(&self) -> Result<(), Self::Err>
Tries to enable the cache of the device.
sourcefn try_disable_cache(&self) -> Result<(), Self::Err>
fn try_disable_cache(&self) -> Result<(), Self::Err>
Tries to disable the cache of the device. See Cache::disable_cache for details of when this is useful.
sourcefn try_empty_cache(&self) -> Result<(), Self::Err>
fn try_empty_cache(&self) -> Result<(), Self::Err>
Tries to empty the cache of the device. See Cache::empty_cache for details of when this is useful.
Provided Methods§
sourcefn enable_cache(&self)
fn enable_cache(&self)
Enables the cache of the device.
sourcefn disable_cache(&self)
fn disable_cache(&self)
Disables the cache of the device. This will also empty the cache if there are things in it. See Cache::empty_cache for more information.
sourcefn empty_cache(&self)
fn empty_cache(&self)
Empties the cache of the device.
Currently devices will cache tensor allocations to avoid allocating and deallocating memory. This results is large speedups, but may potentially hold on to more memory than is actually being used.
This method will empty the cache of the device, freeing all memory that is currently being held.