pub struct CodecTransformerLayer<B: Backend> { /* private fields */ }Expand description
Codec decoder transformer layer.
Architecture:
x -> RmsNorm -> CodecAttention(ALiBi, QK-norm, causal, sliding_window) -> LayerScale -> + residual -> x'
x' -> RmsNorm -> SwiGLU -> LayerScale -> + residual -> outParameters: 8 MHA heads, 1024 dim, head_dim 128, sliding window per block.
Implementations§
Source§impl<B: Backend> CodecTransformerLayer<B>
impl<B: Backend> CodecTransformerLayer<B>
Sourcepub fn new(
attention_norm: RmsNorm<B>,
attention: CodecAttention<B>,
attention_scale: LayerScale<B>,
ffn_norm: RmsNorm<B>,
ffn: SwiGLU<B>,
ffn_scale: LayerScale<B>,
) -> Self
pub fn new( attention_norm: RmsNorm<B>, attention: CodecAttention<B>, attention_scale: LayerScale<B>, ffn_norm: RmsNorm<B>, ffn: SwiGLU<B>, ffn_scale: LayerScale<B>, ) -> Self
Create a codec transformer layer from loaded components.
Sourcepub fn from_safetensors(
safetensors: &SafeTensors<'_>,
prefix: &str,
n_heads: usize,
head_dim: usize,
sliding_window: usize,
norm_eps: f64,
device: &B::Device,
) -> Result<Self>
pub fn from_safetensors( safetensors: &SafeTensors<'_>, prefix: &str, n_heads: usize, head_dim: usize, sliding_window: usize, norm_eps: f64, device: &B::Device, ) -> Result<Self>
Load a codec transformer layer from SafeTensors.
§Arguments
safetensors- SafeTensors dataprefix- Weight name prefix (e.g.,audio_tokenizer.decoder_blocks.0.layers.0)n_heads- Number of attention headshead_dim- Per-head dimensionsliding_window- Sliding window size for this layernorm_eps- RMSNorm epsilondevice- Device for tensor allocation
Auto Trait Implementations§
impl<B> !Freeze for CodecTransformerLayer<B>
impl<B> !RefUnwindSafe for CodecTransformerLayer<B>
impl<B> !Sync for CodecTransformerLayer<B>
impl<B> !UnwindSafe for CodecTransformerLayer<B>
impl<B> Send for CodecTransformerLayer<B>
impl<B> Unpin for CodecTransformerLayer<B>
impl<B> UnsafeUnpin for CodecTransformerLayer<B>where
RmsNorm<B>: UnsafeUnpin,
CodecAttention<B>: UnsafeUnpin,
LayerScale<B>: UnsafeUnpin,
SwiGLU<B>: UnsafeUnpin,
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
Mutably borrows from an owned value. Read more