Struct AttentionModuleOptions
pub struct AttentionModuleOptions {
pub scale: Option<f64>,
pub softcap: Option<f64>,
pub is_causal: bool,
}Expand description
Options for attention.
Fields§
§scale: Option<f64>Custom scale factor applied to QK^T. When None, defaults to 1/sqrt(head_dim).
softcap: Option<f64>Soft capping applied before softmax: softcap * tanh(scores / softcap).
Used by Gemma-2 and similar models. Must be positive when set.
is_causal: boolWhen true, applies causal (autoregressive) masking so that each query position
can only attend to key positions at or before it. This is more efficient than
passing an explicit lower-triangular bool mask because backends can use optimized
kernel paths (e.g. flash attention with causal mode).
Trait Implementations§
§impl Clone for AttentionModuleOptions
impl Clone for AttentionModuleOptions
§fn clone(&self) -> AttentionModuleOptions
fn clone(&self) -> AttentionModuleOptions
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read more§impl Debug for AttentionModuleOptions
impl Debug for AttentionModuleOptions
§impl Default for AttentionModuleOptions
impl Default for AttentionModuleOptions
§fn default() -> AttentionModuleOptions
fn default() -> AttentionModuleOptions
Returns the “default value” for a type. Read more
§impl<'de> Deserialize<'de> for AttentionModuleOptions
impl<'de> Deserialize<'de> for AttentionModuleOptions
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<AttentionModuleOptions, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<AttentionModuleOptions, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
§impl From<AttentionModuleOptions> for AttentionOptionsIr
impl From<AttentionModuleOptions> for AttentionOptionsIr
§fn from(ir: AttentionModuleOptions) -> AttentionOptionsIr
fn from(ir: AttentionModuleOptions) -> AttentionOptionsIr
Converts to this type from the input type.
§impl From<AttentionOptionsIr> for AttentionModuleOptions
impl From<AttentionOptionsIr> for AttentionModuleOptions
§fn from(ir: AttentionOptionsIr) -> AttentionModuleOptions
fn from(ir: AttentionOptionsIr) -> AttentionModuleOptions
Converts to this type from the input type.
§impl PartialEq for AttentionModuleOptions
impl PartialEq for AttentionModuleOptions
§impl Serialize for AttentionModuleOptions
impl Serialize for AttentionModuleOptions
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Copy for AttentionModuleOptions
impl StructuralPartialEq for AttentionModuleOptions
Auto Trait Implementations§
impl Freeze for AttentionModuleOptions
impl RefUnwindSafe for AttentionModuleOptions
impl Send for AttentionModuleOptions
impl Sync for AttentionModuleOptions
impl Unpin for AttentionModuleOptions
impl UnwindSafe for AttentionModuleOptions
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<C> CloneExpand for Cwhere
C: Clone,
impl<C> CloneExpand for Cwhere
C: Clone,
fn __expand_clone_method(&self, _scope: &mut Scope) -> C
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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