pub struct Encoder {
pub config: EncoderConfig,
pub attention: MultiHeadAttention,
pub ffn: FeedForward,
pub norm1: LayerNorm,
pub norm2: LayerNorm,
}Expand description
Transformer encoder layer
Fields§
§config: EncoderConfigConfiguration
attention: MultiHeadAttentionMulti-head attention
ffn: FeedForwardFeed-forward network
norm1: LayerNormFirst layer normalization
norm2: LayerNormSecond layer normalization
Implementations§
Source§impl Encoder
impl Encoder
Sourcepub fn new(config: EncoderConfig) -> Result<Self>
pub fn new(config: EncoderConfig) -> Result<Self>
Create a new encoder layer
Sourcepub fn build_encoder_graph(&self, graph: &mut EinsumGraph) -> Result<Vec<usize>>
pub fn build_encoder_graph(&self, graph: &mut EinsumGraph) -> Result<Vec<usize>>
Build einsum graph for encoder layer
Input tensors:
- 0: x (input) [batch, seq_len, d_model]
- 1-N: weight matrices and parameters for attention, FFN, and layer norms
Output tensors:
- output: [batch, seq_len, d_model]
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Encoder
impl RefUnwindSafe for Encoder
impl Send for Encoder
impl Sync for Encoder
impl Unpin for Encoder
impl UnwindSafe for Encoder
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