Trait dfdx::tensor::Cache

source ·
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§

source

fn try_enable_cache(&self) -> Result<(), Self::Err>

Tries to enable the cache of the device.

source

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.

source

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§

source

fn enable_cache(&self)

Enables the cache of the device.

source

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.

source

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.

Implementors§