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 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