Skip to main content

Mamba1Caches

Struct Mamba1Caches 

Source
pub struct Mamba1Caches {
    pub caches: Vec<Mamba1Cache>,
}
Expand description

A collection of per-layer caches for a complete Mamba-1 network.

During autoregressive decoding a Mamba1Caches instance is threaded through every layer-stack step call (the family-generic [crate::generic::Layers]). Each element corresponds to one (virtual) layer in the network.

Fields§

§caches: Vec<Mamba1Cache>

Per-layer caches.

Length: n_real_caches (the number of virtual layers, which may exceed the number of real weight layers when weight-sharing / layer scheduling is in use).

Implementations§

Source§

impl Mamba1Caches

Source

pub fn caches_len(&self) -> usize

Number of per-layer caches.

Source

pub fn from_vec(vec: Vec<Mamba1Cache>) -> Self

Wrap a vector of per-layer caches.

Source

pub fn into_options(self) -> Vec<Option<Mamba1Cache>>

Wrap each per-layer cache in Some so the layer loop can take it without cloning (Burn tensors are reference-counted).

Source

pub fn from_options(options: Vec<Option<Mamba1Cache>>) -> Self

Inverse of Self::into_options: unwrap each slot and re-bundle.

Trait Implementations§

Source§

impl AutodiffModule for Mamba1Caches

Source§

fn valid(&self) -> Self

Returns the same module, but on the inner backend without auto-differentiation.
Source§

fn from_inner(module: Self) -> Self

Wraps an inner module back into an auto-diff module.
Source§

impl CacheStack for Mamba1Caches

Source§

type Cache = Mamba1Cache

The per-layer cache element.
Source§

fn slot_count(&self) -> usize

Number of per-(virtual-)layer slots.
Source§

fn into_slots(self) -> Vec<Option<Mamba1Cache>>

Move each slot into an Option so the loop can take without cloning.
Source§

fn from_slots(slots: Vec<Option<Mamba1Cache>>) -> Self

Inverse of Self::into_slots.
Source§

impl Clone for Mamba1Caches

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Mamba1Caches

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Mamba1Caches

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Module for Mamba1Caches

Source§

fn num_params(&self) -> usize

Get the number of parameters the module has, including all of its sub-modules.
Source§

fn visit<Visitor: ModuleVisitor>(&self, visitor: &mut Visitor)

Visit each tensor parameter in the module with a visitor.
Source§

fn map<Mapper: ModuleMapper>(self, mapper: &mut Mapper) -> Self

Map each tensor parameter in the module with a mapper.
Source§

fn collect_devices(&self, devices: Devices) -> Devices

Return all the devices found in the underneath module tree added to the given vector without duplicates.
Source§

fn to_device(self, device: &Device) -> Self

Move the module and all of its sub-modules to the given device. Read more
Source§

fn fork(self, device: &Device) -> Self

Fork the module and all of its sub-modules to the given device. Read more
§

fn devices(&self) -> Vec<Device>

Return all the devices found in the underneath module tree without duplicates.
§

fn no_grad(self) -> Self

Each tensor in the module tree will not require grad. Read more
§

fn train(self) -> Self
where Self: AutodiffModule,

Move the module and all of its sub-modules to the autodiff backend. Read more
§

fn quantize_weights(self, quantizer: &mut Quantizer) -> Self

Quantize the weights of the module.
§

fn into_record(self) -> ModuleRecord
where Self: Sized,

Collect this module’s parameters into a ModuleRecord. Read more
§

fn try_load_record(self, record: ModuleRecord) -> Result<Self, RecordError>
where Self: Sized,

Apply a ModuleRecord to this module, returning the loaded module. Read more
§

fn load_record(self, record: ModuleRecord) -> Self
where Self: Sized,

Apply a ModuleRecord to this module, consuming and returning it. Read more
Source§

impl ModuleDisplay for Mamba1Caches

§

fn format(&self, passed_settings: DisplaySettings) -> String

Formats the module with provided display settings. Read more
§

fn custom_settings(&self) -> Option<DisplaySettings>

Custom display settings for the module. Read more
§

fn custom_content(&self, _content: Content) -> Option<Content>

Custom attributes for the module. Read more
Source§

impl ModuleDisplayDefault for Mamba1Caches

Source§

fn content(&self, content: Content) -> Option<Content>

Attributes of the module used for display purposes. Read more
Source§

fn num_params(&self) -> usize

Gets the number of the parameters of the module.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.