pub struct EncoderLayer {
pub config: EncoderLayerConfig,
pub attention: MultiHeadAttention,
pub ffn: FeedForward,
pub norm1: LayerNorm,
pub norm2: LayerNorm,
}Expand description
Transformer encoder layer
Fields§
§config: EncoderLayerConfigConfiguration
attention: MultiHeadAttentionMulti-head attention
ffn: FeedForwardFeed-forward network
norm1: LayerNormFirst layer normalization
norm2: LayerNormSecond layer normalization
Implementations§
Source§impl EncoderLayer
impl EncoderLayer
Sourcepub fn new(config: EncoderLayerConfig) -> Result<Self>
pub fn new(config: EncoderLayerConfig) -> Result<Self>
Create a new encoder layer
Sourcepub fn build_encoder_layer_graph(
&self,
graph: &mut EinsumGraph,
) -> Result<Vec<usize>>
pub fn build_encoder_layer_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§
Source§impl Clone for EncoderLayer
impl Clone for EncoderLayer
Source§fn clone(&self) -> EncoderLayer
fn clone(&self) -> EncoderLayer
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 EncoderLayer
impl RefUnwindSafe for EncoderLayer
impl Send for EncoderLayer
impl Sync for EncoderLayer
impl Unpin for EncoderLayer
impl UnwindSafe for EncoderLayer
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