pub struct LearnedPositionEncoding {
pub config: PositionEncodingConfig,
}Expand description
Learned position encoding
Fields§
§config: PositionEncodingConfigConfiguration
Implementations§
Source§impl LearnedPositionEncoding
impl LearnedPositionEncoding
Sourcepub fn new(config: PositionEncodingConfig) -> Result<Self>
pub fn new(config: PositionEncodingConfig) -> Result<Self>
Create a new learned position encoding
Sourcepub fn build_encoding_graph(
&self,
graph: &mut EinsumGraph,
) -> Result<Vec<usize>>
pub fn build_encoding_graph( &self, graph: &mut EinsumGraph, ) -> Result<Vec<usize>>
Build einsum graph for learned position encoding
Input tensors:
- 0: x (input) [batch, seq_len, d_model]
- 1: position_embeddings [max_seq_len, d_model] (learned parameter)
- 2: position_ids [batch, seq_len] (optional)
Output tensors:
- output: [batch, seq_len, d_model] (x + position_embedding)
Sourcepub fn max_seq_len(&self) -> usize
pub fn max_seq_len(&self) -> usize
Get maximum sequence length
Trait Implementations§
Source§impl Clone for LearnedPositionEncoding
impl Clone for LearnedPositionEncoding
Source§fn clone(&self) -> LearnedPositionEncoding
fn clone(&self) -> LearnedPositionEncoding
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 LearnedPositionEncoding
impl RefUnwindSafe for LearnedPositionEncoding
impl Send for LearnedPositionEncoding
impl Sync for LearnedPositionEncoding
impl Unpin for LearnedPositionEncoding
impl UnsafeUnpin for LearnedPositionEncoding
impl UnwindSafe for LearnedPositionEncoding
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