pub struct DecoderLayer {
pub config: DecoderLayerConfig,
pub self_attention: MultiHeadAttention,
pub cross_attention: MultiHeadAttention,
pub ffn: FeedForward,
pub norm1: LayerNorm,
pub norm2: LayerNorm,
pub norm3: LayerNorm,
}Expand description
Transformer decoder layer
Fields§
§config: DecoderLayerConfigConfiguration
self_attention: MultiHeadAttentionMasked self-attention
cross_attention: MultiHeadAttentionCross-attention
ffn: FeedForwardFeed-forward network
norm1: LayerNormFirst layer normalization (self-attention)
norm2: LayerNormSecond layer normalization (cross-attention)
norm3: LayerNormThird layer normalization (FFN)
Implementations§
Source§impl DecoderLayer
impl DecoderLayer
Sourcepub fn new(config: DecoderLayerConfig) -> Result<Self>
pub fn new(config: DecoderLayerConfig) -> Result<Self>
Create a new decoder layer
Sourcepub fn build_decoder_layer_graph(
&self,
graph: &mut EinsumGraph,
) -> Result<Vec<usize>>
pub fn build_decoder_layer_graph( &self, graph: &mut EinsumGraph, ) -> Result<Vec<usize>>
Build einsum graph for decoder layer
Input tensors:
- 0: x (decoder input) [batch, tgt_len, d_model]
- 1: encoder_output [batch, src_len, d_model]
- 2-N: weight matrices and parameters
Output tensors:
- output: [batch, tgt_len, d_model]
Trait Implementations§
Source§impl Clone for DecoderLayer
impl Clone for DecoderLayer
Source§fn clone(&self) -> DecoderLayer
fn clone(&self) -> DecoderLayer
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for DecoderLayer
impl RefUnwindSafe for DecoderLayer
impl Send for DecoderLayer
impl Sync for DecoderLayer
impl Unpin for DecoderLayer
impl UnwindSafe for DecoderLayer
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