Skip to main content

PositionOps

Trait PositionOps 

Source
pub trait PositionOps: Send + Sync {
    // Required method
    fn rotary_embedding(
        &self,
        x: &TensorRef,
        cos_cache: &TensorRef,
        sin_cache: &TensorRef,
        position_ids: &[usize],
    ) -> Result<TensorRef>;
}
Expand description

Positional encoding operations.

Required Methods§

Source

fn rotary_embedding( &self, x: &TensorRef, cos_cache: &TensorRef, sin_cache: &TensorRef, position_ids: &[usize], ) -> Result<TensorRef>

Apply rotary position embedding to a Q or K tensor.

x shape: [batch, seq_len, num_heads, head_dim] position_ids: position indices for each token in the sequence. cos_cache / sin_cache: precomputed [max_seq_len, head_dim/2].

Implementors§