Skip to main content

WaveNetLayerArray

Struct WaveNetLayerArray 

Source
pub struct WaveNetLayerArray<const IN: usize, const COND: usize, const CH: usize, const K: usize, const HEAD: usize> {
    pub layers: Vec<WaveNetLayer<COND, CH, K>>,
    pub states: Vec<WaveNetLayerState>,
    pub rechannel: DenseLayer<IN, CH>,
    pub head_rechannel: DenseLayer<CH, HEAD>,
    pub array_outputs: AlignedVec<f32>,
    pub head_accum: AlignedVec<f32>,
    pub head_outputs: AlignedVec<f32>,
    pub receptive_field_size: usize,
    pub block_size: usize,
    pub block_buffer: AlignedVec<f32>,
    pub effective_layers: usize,
}
Expand description

Grouped Multi-Layer WaveNet Unit.

Fields§

§layers: Vec<WaveNetLayer<COND, CH, K>>

Vec with structural topology (length defines blocks).

§states: Vec<WaveNetLayerState>

RingBuffer states, one for each Layer in the system.

§rechannel: DenseLayer<IN, CH>

Initial Dense tensor opening.

§head_rechannel: DenseLayer<CH, HEAD>

Final tensor closure generating Head projection.

§array_outputs: AlignedVec<f32>

Pre-allocated temporary output array. Array output temporary accumulator.

§head_accum: AlignedVec<f32>

CH-sized intermediate accumulator for layer contributions before the Head projection.

§head_outputs: AlignedVec<f32>

Allocated global Linear projection memory (HEAD-sized).

§receptive_field_size: usize

Dimensional field size (global receptive field) for routing.

§block_size: usize

Shared activation buffer size.

§block_buffer: AlignedVec<f32>

Temporary accumulator for blocks (pre-allocated).

§effective_layers: usize

Active number of layers for soft-degrade. Set to layers.len() by default.

Implementations§

Source§

impl<const IN: usize, const COND: usize, const CH: usize, const K: usize, const HEAD: usize> WaveNetLayerArray<IN, COND, CH, K, HEAD>

Source

pub fn set_effective_layers(&mut self, n: usize)

Sets the effective number of layers for soft-degrade. Clamped to [1, layers.len()].

Source

pub unsafe fn process_block_internal<M: SimdMath, const PREWARM: bool>( &mut self, layer_inputs: &[f32], condition: &[f32], num_frames: usize, prev_head_outputs: Option<&[f32]>, )

Array’s central processing. Fully shielded against allocations.

When prev_head_outputs is Some, it is passed as seed in the first layer’s WavenetProcessContext — the layer then fuses seed accumulation with tanh in a single SIMD pass. This eliminates the dedicated copy_from_slice of num_frames * CH bytes.

This implements the C++ cascaded head pattern (array N seeds its head accumulator with the post-head_rechannel output of array N−1).

§Safety

State pointers iterate internally without bounds checks.

Source

pub unsafe fn prewarm_internal<M: SimdMath>( &mut self, layer_inputs: &[f32], condition: &[f32], prev_head_outputs: Option<&[f32]>, )

Processes data in Pre-warm mode to initialize and stabilize temporal memory.

[SCIENTIFIC EXPLANATION] Causal convolution neural networks like WaveNet have an internal state that actively depends on N past steps (Receptive Field). When loading a fresh model, the allocated network memory (Ring Buffers) contains “pure zeros” or computational garbage. Pre-warm feeds a continuous inert signal (Absolute Silence) into the network so as to fill the entire past window. The resulting cold-start transients “drain” silently into oblivion, ensuring the first audio sample when turning on the device sounds organic and stable, without pops or clicks.

§Safety

Call this via dispatch_simd! macro only.

Auto Trait Implementations§

§

impl<const IN: usize, const COND: usize, const CH: usize, const K: usize, const HEAD: usize> Freeze for WaveNetLayerArray<IN, COND, CH, K, HEAD>

§

impl<const IN: usize, const COND: usize, const CH: usize, const K: usize, const HEAD: usize> RefUnwindSafe for WaveNetLayerArray<IN, COND, CH, K, HEAD>

§

impl<const IN: usize, const COND: usize, const CH: usize, const K: usize, const HEAD: usize> Send for WaveNetLayerArray<IN, COND, CH, K, HEAD>

§

impl<const IN: usize, const COND: usize, const CH: usize, const K: usize, const HEAD: usize> Sync for WaveNetLayerArray<IN, COND, CH, K, HEAD>

§

impl<const IN: usize, const COND: usize, const CH: usize, const K: usize, const HEAD: usize> Unpin for WaveNetLayerArray<IN, COND, CH, K, HEAD>

§

impl<const IN: usize, const COND: usize, const CH: usize, const K: usize, const HEAD: usize> UnsafeUnpin for WaveNetLayerArray<IN, COND, CH, K, HEAD>

§

impl<const IN: usize, const COND: usize, const CH: usize, const K: usize, const HEAD: usize> UnwindSafe for WaveNetLayerArray<IN, COND, CH, K, HEAD>

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
Source§

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

Source§

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

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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.

Source§

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

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(value: T, _simd: S) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

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.