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 new(
d_model: usize,
d_context: usize,
n_heads: usize,
n_heads_kv: usize,
d_head: usize,
) -> CrossAttentionConfig
pub fn new( d_model: usize, d_context: usize, n_heads: usize, n_heads_kv: usize, d_head: usize, ) -> CrossAttentionConfig
Create a new instance of the config.
§Arguments
§Required Arguments
§d_model
Dimension of the Query (e.g., Decoder state).
§d_context
Dimension of the Context (e.g., Encoder audio embeddings).
§n_heads
Number of heads for the Query.
§n_heads_kv
Number of heads for Key/Value (Set to 1 for MQA, set to n_heads for MHA).
§d_head
Dimension of a single head.
§Default Arguments
§dropout
Dropout rate.
- Defaults to
0.1
§min_float
Masking value. Use -1.0e4 for f16/bf16 safety.
- Defaults to
-1.0e4
§quiet_softmax
Use quiet_softmax to allow zero-attention (good for sparse/quantized models).
- Defaults to
false
§impl CrossAttentionConfig
impl CrossAttentionConfig
pub fn with_dropout(self, dropout: f64) -> CrossAttentionConfig
pub fn with_dropout(self, dropout: f64) -> CrossAttentionConfig
pub fn with_min_float(self, min_float: f64) -> CrossAttentionConfig
pub fn with_min_float(self, min_float: f64) -> CrossAttentionConfig
Sets the value for the field min_float.
Masking value. Use -1.0e4 for f16/bf16 safety.
- Defaults to
-1.0e4
pub fn with_quiet_softmax(self, quiet_softmax: bool) -> CrossAttentionConfig
pub fn with_quiet_softmax(self, quiet_softmax: bool) -> CrossAttentionConfig
Sets the value for the field quiet_softmax.
Use quiet_softmax to allow zero-attention (good for sparse/quantized models).
- Defaults to
false
§impl CrossAttentionConfig
impl CrossAttentionConfig
pub fn init(&self, device: &Device) -> CrossAttention
pub fn init(&self, device: &Device) -> CrossAttention
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
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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>,
§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,
Auto Trait Implementations§
impl Freeze for CrossAttentionConfig
impl RefUnwindSafe for CrossAttentionConfig
impl Send for CrossAttentionConfig
impl Sync for CrossAttentionConfig
impl Unpin for CrossAttentionConfig
impl UnsafeUnpin 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
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<K, Q> Comparable<Q> for K
impl<K, Q> Comparable<Q> for K
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<K, Q> Equivalent<Q> for K
impl<K, Q> Equivalent<Q> for K
§fn equivalent(&self, key: &Q) -> bool
fn equivalent(&self, key: &Q) -> bool
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
§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>
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>
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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§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>
ToCompactString::to_compact_string()] Read more§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString]. Read more