pub struct LayerNorm {
pub config: LayerNormConfig,
}Expand description
Layer normalization component
Fields§
§config: LayerNormConfigConfiguration
Implementations§
Source§impl LayerNorm
impl LayerNorm
Sourcepub fn new(config: LayerNormConfig) -> Result<Self>
pub fn new(config: LayerNormConfig) -> Result<Self>
Create a new layer normalization component
Sourcepub fn build_layernorm_graph(
&self,
graph: &mut EinsumGraph,
) -> Result<Vec<usize>>
pub fn build_layernorm_graph( &self, graph: &mut EinsumGraph, ) -> Result<Vec<usize>>
Build einsum graph for layer normalization
Input tensors:
- 0: x (input)
[batch, seq_len, d_model] - 1: gamma (scale)
[d_model](if elementwise_affine) - 2: beta (shift)
[d_model](if elementwise_affine)
Output tensors:
- output:
[batch, seq_len, d_model](normalized)
Sourcepub fn has_elementwise_affine(&self) -> bool
pub fn has_elementwise_affine(&self) -> bool
Check if using elementwise affine
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LayerNorm
impl RefUnwindSafe for LayerNorm
impl Send for LayerNorm
impl Sync for LayerNorm
impl Unpin for LayerNorm
impl UnsafeUnpin for LayerNorm
impl UnwindSafe for LayerNorm
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