Struct dfdx::nn::TransformerDecoder
source · [−]pub struct TransformerDecoder<const M: usize, const N: usize, const I: usize, const L: usize, const H: usize> where
Assert<{ _ }>: ConstTrue, {
pub blocks: [TransformerDecoderBlock<M, N, I, M, H>; L],
}
Expand description
Requires Nightly A transformer decoder.
Generics
M
The embedding size of token vectors.N
The size of encoder vectors.I
The inner size of the feedforward layers.L
The number of layers.H
The number of heads for self attention. TODO: Doctests
Fields
blocks: [TransformerDecoderBlock<M, N, I, M, H>; L]
Trait Implementations
sourceimpl<const M: usize, const N: usize, const I: usize, const L: usize, const H: usize> CanUpdateWithGradients for TransformerDecoder<M, N, I, L, H> where
Assert<{ _ }>: ConstTrue,
impl<const M: usize, const N: usize, const I: usize, const L: usize, const H: usize> CanUpdateWithGradients for TransformerDecoder<M, N, I, L, H> where
Assert<{ _ }>: ConstTrue,
sourcefn update<G: GradientProvider>(
&mut self,
grads: &mut G,
unused: &mut UnusedTensors
)
fn update<G: GradientProvider>(
&mut self,
grads: &mut G,
unused: &mut UnusedTensors
)
Updates self given the GradientProvider. When any parameters that
are NOT present in G
, then this function should
add the tensor’s UniqueId to UnusedTensors. Read more
sourceimpl<const M: usize, const N: usize, const I: usize, const L: usize, const H: usize> Debug for TransformerDecoder<M, N, I, L, H> where
Assert<{ _ }>: ConstTrue,
impl<const M: usize, const N: usize, const I: usize, const L: usize, const H: usize> Debug for TransformerDecoder<M, N, I, L, H> where
Assert<{ _ }>: ConstTrue,
sourceimpl<const M: usize, const N: usize, const I: usize, const L: usize, const H: usize> Default for TransformerDecoder<M, N, I, L, H> where
Assert<{ _ }>: ConstTrue,
[TransformerDecoderBlock<M, N, I, M, H>; L]: Default,
impl<const M: usize, const N: usize, const I: usize, const L: usize, const H: usize> Default for TransformerDecoder<M, N, I, L, H> where
Assert<{ _ }>: ConstTrue,
[TransformerDecoderBlock<M, N, I, M, H>; L]: Default,
sourceimpl<const M: usize, const N: usize, const I: usize, const L: usize, const H: usize, const S1: usize, const S2: usize, T: 'static + Tape> Module<(Tensor2D<S1, M, T>, Tensor2D<S2, N, T>)> for TransformerDecoder<M, N, I, L, H> where
Assert<{ _ }>: ConstTrue,
Assert<{ _ }>: ConstTrue,
Assert<{ _ }>: ConstTrue,
Assert<{ _ }>: ConstTrue,
impl<const M: usize, const N: usize, const I: usize, const L: usize, const H: usize, const S1: usize, const S2: usize, T: 'static + Tape> Module<(Tensor2D<S1, M, T>, Tensor2D<S2, N, T>)> for TransformerDecoder<M, N, I, L, H> where
Assert<{ _ }>: ConstTrue,
Assert<{ _ }>: ConstTrue,
Assert<{ _ }>: ConstTrue,
Assert<{ _ }>: ConstTrue,
sourcefn forward(
&self,
input: (Tensor2D<S1, M, T>, Tensor2D<S2, N, T>)
) -> Self::Output
fn forward(
&self,
input: (Tensor2D<S1, M, T>, Tensor2D<S2, N, T>)
) -> Self::Output
Pass an Input
through the unit and produce Self::Output.
Can be implemented for multiple Input
types. Read more
sourcefn forward_mut(&mut self, input: Input) -> Self::Output
fn forward_mut(&mut self, input: Input) -> Self::Output
Pass an Input
through the unit and produce Self::Output.
Can be implemented for multiple Input
types. Read more
sourceimpl<const M: usize, const N: usize, const I: usize, const L: usize, const H: usize, const S1: usize, const S2: usize, const B: usize, T: 'static + Tape> Module<(Tensor3D<B, S1, M, T>, Tensor3D<B, S2, N, NoneTape>)> for TransformerDecoder<M, N, I, L, H> where
Assert<{ _ }>: ConstTrue,
Assert<{ _ }>: ConstTrue,
Assert<{ _ }>: ConstTrue,
Assert<{ _ }>: ConstTrue,
impl<const M: usize, const N: usize, const I: usize, const L: usize, const H: usize, const S1: usize, const S2: usize, const B: usize, T: 'static + Tape> Module<(Tensor3D<B, S1, M, T>, Tensor3D<B, S2, N, NoneTape>)> for TransformerDecoder<M, N, I, L, H> where
Assert<{ _ }>: ConstTrue,
Assert<{ _ }>: ConstTrue,
Assert<{ _ }>: ConstTrue,
Assert<{ _ }>: ConstTrue,
sourcefn forward(
&self,
input: (Tensor3D<B, S1, M, T>, Tensor3D<B, S2, N>)
) -> Self::Output
fn forward(
&self,
input: (Tensor3D<B, S1, M, T>, Tensor3D<B, S2, N>)
) -> Self::Output
Pass an Input
through the unit and produce Self::Output.
Can be implemented for multiple Input
types. Read more
sourcefn forward_mut(&mut self, input: Input) -> Self::Output
fn forward_mut(&mut self, input: Input) -> Self::Output
Pass an Input
through the unit and produce Self::Output.
Can be implemented for multiple Input
types. Read more
sourceimpl<const M: usize, const N: usize, const I: usize, const L: usize, const H: usize> ResetParams for TransformerDecoder<M, N, I, L, H> where
Assert<{ _ }>: ConstTrue,
impl<const M: usize, const N: usize, const I: usize, const L: usize, const H: usize> ResetParams for TransformerDecoder<M, N, I, L, H> where
Assert<{ _ }>: ConstTrue,
Auto Trait Implementations
impl<const M: usize, const N: usize, const I: usize, const L: usize, const H: usize> RefUnwindSafe for TransformerDecoder<M, N, I, L, H>
impl<const M: usize, const N: usize, const I: usize, const L: usize, const H: usize> !Send for TransformerDecoder<M, N, I, L, H>
impl<const M: usize, const N: usize, const I: usize, const L: usize, const H: usize> !Sync for TransformerDecoder<M, N, I, L, H>
impl<const M: usize, const N: usize, const I: usize, const L: usize, const H: usize> Unpin for TransformerDecoder<M, N, I, L, H>
impl<const M: usize, const N: usize, const I: usize, const L: usize, const H: usize> UnwindSafe for TransformerDecoder<M, N, I, L, H>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more