pub struct PostStackHead {
pub conv: Conv1dDyn,
pub activation: ActivationType,
pub state: WaveNetLayerState,
/* private fields */
}Expand description
Post-stack head sub-object for WaveNet / ConvNet architectures.
Contains a causal Conv1D + activation that processes the signal
after the stack of layer arrays, before the final head_scale gain.
Mirrors the _Head structure in NAMCore’s convnet.h:108-118.
Fields§
§conv: Conv1dDynCausal 1D convolution (dynamic runtime dimensions).
activation: ActivationTypeActivation function applied after convolution.
state: WaveNetLayerStateRing buffer state for causal convolution lookback.
Implementations§
Source§impl PostStackHead
impl PostStackHead
Sourcepub fn from_config(config: &HeadConfig, in_channels: usize) -> Result<Self>
pub fn from_config(config: &HeadConfig, in_channels: usize) -> Result<Self>
Creates a new PostStackHead from the parsed HeadConfig and the
input channel count from the last layer array.
Missing fields in HeadConfig fall back to sensible defaults:
channels→in_channels(same as the last array’s head projection)out_channels→ 1 (mono output)kernel_size→ 3bias→ falseactivation→ “Tanh”
Weight and bias arrays are zero-initialized and must be populated
by the dispatcher via set_weights and set_bias.
Sourcepub fn receptive_field(&self) -> usize
pub fn receptive_field(&self) -> usize
Returns the receptive field contribution of this head (kernel size). Must be added to the global model receptive field for prewarm.
Sourcepub fn out_channels(&self) -> usize
pub fn out_channels(&self) -> usize
Number of output channels produced by this head.
Sourcepub fn in_channels(&self) -> usize
pub fn in_channels(&self) -> usize
Number of input channels expected by this head.
Sourcepub fn set_weights(&mut self, weights: &[f32])
pub fn set_weights(&mut self, weights: &[f32])
Loads convolution weights from a flat f32 slice.
Sourcepub fn set_bias(&mut self, bias: &[f32])
pub fn set_bias(&mut self, bias: &[f32])
Loads convolution bias from a flat f32 slice, if present.
Sourcepub unsafe fn process_block(
&mut self,
input: &[f32],
output: &mut [f32],
num_frames: usize,
)
pub unsafe fn process_block( &mut self, input: &[f32], output: &mut [f32], num_frames: usize, )
Public dispatch wrapper that selects the optimal SIMD path.
§Safety
Input and output slices must have sizes compatible with the head dimensions:
input.len() == num_frames * in_ch, output.len() == num_frames * out_ch.
The ring buffer state must have been properly initialized (via prewarm or
sufficient prior processing) to cover the causal receptive field.
Sourcepub unsafe fn process_block_internal<M: SimdMath>(
&mut self,
input: &[f32],
output: &mut [f32],
num_frames: usize,
)
pub unsafe fn process_block_internal<M: SimdMath>( &mut self, input: &[f32], output: &mut [f32], num_frames: usize, )
SIMD-dispatched processing kernel.
Writes num_frames of input into the ring buffer, runs the causal
Conv1D, applies activation, and writes results to output.
Input layout: frame-interleaved [f0_c0, f0_c1, ..., f1_c0, ...].
Output layout: frame-interleaved [f0_c0, f0_c1, ..., f1_c0, ...].
§Safety
input and output must have sizes num_frames * in_ch and
num_frames * out_ch respectively. The ring buffer must have been
properly initialized.
Sourcepub unsafe fn prewarm_internal<M: SimdMath>(&mut self)
pub unsafe fn prewarm_internal<M: SimdMath>(&mut self)
Fills the conv state buffer with a single frame of silence replicated backward to cover the entire receptive field.
§Safety
Must be called via dispatch_simd! macro. The state buffer must be
properly allocated and the ring buffer start pointer must be valid.
Trait Implementations§
Source§impl Clone for PostStackHead
impl Clone for PostStackHead
Source§fn clone(&self) -> PostStackHead
fn clone(&self) -> PostStackHead
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for PostStackHead
impl RefUnwindSafe for PostStackHead
impl Send for PostStackHead
impl Sync for PostStackHead
impl Unpin for PostStackHead
impl UnsafeUnpin for PostStackHead
impl UnwindSafe for PostStackHead
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.