pub struct HybridLinearAttentionNeuron {
pub v: f64,
state_kv: Vec<f64>,
pub dim: usize,
pub lambda: f64,
pub window_size: usize,
window_buf: Vec<f64>,
window_idx: usize,
pub dt: f64,
}Expand description
Hybrid linear attention neuron for spiking environments.
Combines local windowed attention with linear (kernel-based) global attention, achieving near-linear training complexity O(L) instead of O(L²). Inspired by SpikingBrain’s hybrid attention architecture.
The neuron accumulates spike-weighted keys and values via a recurrent state S, avoiding the quadratic attention matrix:
S(t+1) = λ S(t) + φ(k_t) ⊗ v_t output = φ(q_t)ᵀ S(t)
where φ is an elu+1 feature map.
Fields§
§v: f64§state_kv: Vec<f64>§dim: usize§lambda: f64§window_size: usize§window_buf: Vec<f64>§window_idx: usize§dt: f64Implementations§
Trait Implementations§
Source§impl Clone for HybridLinearAttentionNeuron
impl Clone for HybridLinearAttentionNeuron
Source§fn clone(&self) -> HybridLinearAttentionNeuron
fn clone(&self) -> HybridLinearAttentionNeuron
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for HybridLinearAttentionNeuron
impl Debug for HybridLinearAttentionNeuron
Auto Trait Implementations§
impl Freeze for HybridLinearAttentionNeuron
impl RefUnwindSafe for HybridLinearAttentionNeuron
impl Send for HybridLinearAttentionNeuron
impl Sync for HybridLinearAttentionNeuron
impl Unpin for HybridLinearAttentionNeuron
impl UnsafeUnpin for HybridLinearAttentionNeuron
impl UnwindSafe for HybridLinearAttentionNeuron
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,
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