pub struct RotaryEmbedding { /* private fields */ }Expand description
Precomputed Rotary Position Embedding (cos, sin) supporting differentiable rope_slow
as well as partial and proportional RoPE (p-RoPE).
Implementations§
Source§impl RotaryEmbedding
impl RotaryEmbedding
Sourcepub fn new(
head_dim: usize,
max_seq: usize,
rope_theta: f64,
dtype: DType,
device: &Device,
) -> Result<Self>
pub fn new( head_dim: usize, max_seq: usize, rope_theta: f64, dtype: DType, device: &Device, ) -> Result<Self>
Precompute (max_seq, head_dim / 2) cosine and sine tables using standard full-head RoPE.
§Errors
Returns an error if head_dim is odd or tensor creation fails.
Sourcepub fn new_with_config(
head_dim: usize,
max_seq: usize,
rope_theta: f64,
partial_rotary_factor: f64,
scale_factor: f64,
mode: RopeMode,
dtype: DType,
device: &Device,
) -> Result<Self>
pub fn new_with_config( head_dim: usize, max_seq: usize, rope_theta: f64, partial_rotary_factor: f64, scale_factor: f64, mode: RopeMode, dtype: DType, device: &Device, ) -> Result<Self>
Precompute (max_seq, head_dim / 2) cosine and sine tables with partial/proportional RoPE options.
§Errors
Returns an error if head_dim is odd, partial_rotary_factor is outside (0.0, 1.0],
scale_factor <= 0.0, or tensor creation fails.
Trait Implementations§
Source§impl Clone for RotaryEmbedding
impl Clone for RotaryEmbedding
Auto Trait Implementations§
impl !RefUnwindSafe for RotaryEmbedding
impl !UnwindSafe for RotaryEmbedding
impl Freeze for RotaryEmbedding
impl Send for RotaryEmbedding
impl Sync for RotaryEmbedding
impl Unpin for RotaryEmbedding
impl UnsafeUnpin for RotaryEmbedding
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,
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
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