Struct CrossAttentionConfig
pub struct CrossAttentionConfig {
pub d_model: usize,
pub d_context: usize,
pub n_heads: usize,
pub n_heads_kv: usize,
pub d_head: usize,
pub dropout: f64,
pub min_float: f64,
pub quiet_softmax: bool,
}Expand description
Configuration to create a CrossAttention layer using the init function.
Fields§
§d_model: usizeDimension of the Query (e.g., Decoder state).
d_context: usizeDimension of the Context (e.g., Encoder audio embeddings).
n_heads: usizeNumber of heads for the Query.
n_heads_kv: usizeNumber of heads for Key/Value (Set to 1 for MQA, set to n_heads for MHA).
d_head: usizeDimension of a single head.
dropout: f64Dropout rate.
min_float: f64Masking value. Use -1.0e4 for f16/bf16 safety.
quiet_softmax: boolUse quiet_softmax to allow zero-attention (good for sparse/quantized models).
Implementations§
§impl CrossAttentionConfig
impl CrossAttentionConfig
pub fn with_dropout(self, dropout: f64) -> CrossAttentionConfig
pub fn with_dropout(self, dropout: f64) -> CrossAttentionConfig
Dropout rate.
pub fn with_min_float(self, min_float: f64) -> CrossAttentionConfig
pub fn with_min_float(self, min_float: f64) -> CrossAttentionConfig
Masking value. Use -1.0e4 for f16/bf16 safety.
pub fn with_quiet_softmax(self, quiet_softmax: bool) -> CrossAttentionConfig
pub fn with_quiet_softmax(self, quiet_softmax: bool) -> CrossAttentionConfig
Use quiet_softmax to allow zero-attention (good for sparse/quantized models).
§impl CrossAttentionConfig
impl CrossAttentionConfig
pub fn init<B>(&self, device: &<B as Backend>::Device) -> CrossAttention<B>where
B: Backend,
pub fn init<B>(&self, device: &<B as Backend>::Device) -> CrossAttention<B>where
B: Backend,
Initializes a new cross-attention module.
§Arguments
device- The device on which to initialize the module.
§Returns
A new CrossAttention module.
Trait Implementations§
§impl Clone for CrossAttentionConfig
impl Clone for CrossAttentionConfig
§fn clone(&self) -> CrossAttentionConfig
fn clone(&self) -> CrossAttentionConfig
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 Config for CrossAttentionConfig
impl Config for CrossAttentionConfig
§impl Debug for CrossAttentionConfig
impl Debug for CrossAttentionConfig
§impl<'de> Deserialize<'de> for CrossAttentionConfig
impl<'de> Deserialize<'de> for CrossAttentionConfig
§fn deserialize<D>(
deserializer: D,
) -> Result<CrossAttentionConfig, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<CrossAttentionConfig, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
§impl Display for CrossAttentionConfig
impl Display for CrossAttentionConfig
§impl Serialize for CrossAttentionConfig
impl Serialize for CrossAttentionConfig
§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
Auto Trait Implementations§
impl Freeze for CrossAttentionConfig
impl RefUnwindSafe for CrossAttentionConfig
impl Send for CrossAttentionConfig
impl Sync for CrossAttentionConfig
impl Unpin for CrossAttentionConfig
impl UnwindSafe for CrossAttentionConfig
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
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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
Fallible version of [
ToCompactString::to_compact_string()] Read more§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a [
CompactString]. Read more