pub struct DecoderStack {
pub config: DecoderStackConfig,
pub layers: Vec<DecoderLayer>,
pub position_encoding_sin: Option<SinusoidalPositionEncoding>,
pub position_encoding_learned: Option<LearnedPositionEncoding>,
pub final_norm: Option<LayerNorm>,
}Expand description
Transformer decoder stack
Fields§
§config: DecoderStackConfigConfiguration
layers: Vec<DecoderLayer>Decoder layers
position_encoding_sin: Option<SinusoidalPositionEncoding>Position encoding (if sinusoidal)
position_encoding_learned: Option<LearnedPositionEncoding>Position encoding (if learned)
final_norm: Option<LayerNorm>Final layer normalization
Implementations§
Source§impl DecoderStack
impl DecoderStack
Sourcepub fn new(config: DecoderStackConfig) -> Result<Self>
pub fn new(config: DecoderStackConfig) -> Result<Self>
Create a new decoder stack
Sourcepub fn build_decoder_stack_graph(
&self,
graph: &mut EinsumGraph,
) -> Result<Vec<usize>>
pub fn build_decoder_stack_graph( &self, graph: &mut EinsumGraph, ) -> Result<Vec<usize>>
Build einsum graph for decoder stack
Input tensors:
- 0: x (target input) [batch, tgt_len, d_model]
- 1: encoder_output [batch, src_len, d_model]
- 2-N: all parameters
Output tensors:
- output: [batch, tgt_len, d_model]
Sourcepub fn num_layers(&self) -> usize
pub fn num_layers(&self) -> usize
Get number of layers
Trait Implementations§
Source§impl Clone for DecoderStack
impl Clone for DecoderStack
Source§fn clone(&self) -> DecoderStack
fn clone(&self) -> DecoderStack
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 DecoderStack
impl RefUnwindSafe for DecoderStack
impl Send for DecoderStack
impl Sync for DecoderStack
impl Unpin for DecoderStack
impl UnwindSafe for DecoderStack
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