pub struct GraphRoPE { /* private fields */ }Expand description
Graph attention with Rotary Position Embeddings
Implementations§
Source§impl GraphRoPE
impl GraphRoPE
pub fn new(config: RoPEConfig) -> Self
Sourcepub fn apply_rotary(&self, x: &[f32], position: usize) -> Vec<f32>
pub fn apply_rotary(&self, x: &[f32], position: usize) -> Vec<f32>
Apply rotary embedding to a vector at given position
Sourcepub fn compute_with_positions(
&self,
query: &[f32],
keys: &[&[f32]],
values: &[&[f32]],
query_pos: usize,
key_positions: &[usize],
) -> AttentionResult<Vec<f32>>
pub fn compute_with_positions( &self, query: &[f32], keys: &[&[f32]], values: &[&[f32]], query_pos: usize, key_positions: &[usize], ) -> AttentionResult<Vec<f32>>
Compute attention with positional encoding based on graph distances
Sourcepub fn distance_to_position(distance: usize, max_distance: usize) -> usize
pub fn distance_to_position(distance: usize, max_distance: usize) -> usize
Get relative position for graph distance Converts graph hop distance to position index
Trait Implementations§
Source§impl Attention for GraphRoPE
impl Attention for GraphRoPE
Source§fn compute(
&self,
query: &[f32],
keys: &[&[f32]],
values: &[&[f32]],
) -> AttentionResult<Vec<f32>>
fn compute( &self, query: &[f32], keys: &[&[f32]], values: &[&[f32]], ) -> AttentionResult<Vec<f32>>
Computes attention over the given query, keys, and values. Read more
Auto Trait Implementations§
impl Freeze for GraphRoPE
impl RefUnwindSafe for GraphRoPE
impl Send for GraphRoPE
impl Sync for GraphRoPE
impl Unpin for GraphRoPE
impl UnwindSafe for GraphRoPE
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