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 (const: unstable) · 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 UnsafeUnpin 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
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more