pub struct LinearAttention { /* private fields */ }Expand description
Linear attention (Performer-style) with O(n) complexity
Implementations§
Source§impl LinearAttention
impl LinearAttention
pub fn into_reference( val: LinearAttention, env: Env, ) -> Result<Reference<LinearAttention>>
pub fn into_instance(self, env: Env) -> Result<ClassInstance<LinearAttention>>
Source§impl LinearAttention
impl LinearAttention
Sourcepub fn new(dim: u32, num_features: u32) -> Self
pub fn new(dim: u32, num_features: u32) -> Self
Create a new linear attention instance
§Arguments
dim- Embedding dimensionnum_features- Number of random features
Sourcepub fn compute(
&self,
query: Float32Array,
keys: Vec<Float32Array>,
values: Vec<Float32Array>,
) -> Result<Float32Array>
pub fn compute( &self, query: Float32Array, keys: Vec<Float32Array>, values: Vec<Float32Array>, ) -> Result<Float32Array>
Compute linear attention
Sourcepub fn num_features(&self) -> u32
pub fn num_features(&self) -> u32
Get the number of random features
Trait Implementations§
Source§impl FromNapiMutRef for LinearAttention
impl FromNapiMutRef for LinearAttention
Source§unsafe fn from_napi_mut_ref(
env: napi_env,
napi_val: napi_value,
) -> Result<&'static mut Self>
unsafe fn from_napi_mut_ref( env: napi_env, napi_val: napi_value, ) -> Result<&'static mut Self>
Safety Read more
Source§impl FromNapiRef for LinearAttention
impl FromNapiRef for LinearAttention
Source§unsafe fn from_napi_ref(
env: napi_env,
napi_val: napi_value,
) -> Result<&'static Self>
unsafe fn from_napi_ref( env: napi_env, napi_val: napi_value, ) -> Result<&'static Self>
Safety Read more
Source§impl FromNapiValue for &LinearAttention
impl FromNapiValue for &LinearAttention
Source§unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
Safety Read more
fn from_unknown(value: JsUnknown) -> Result<Self, Error>
Source§impl FromNapiValue for &mut LinearAttention
impl FromNapiValue for &mut LinearAttention
Source§unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
Safety Read more
fn from_unknown(value: JsUnknown) -> Result<Self, Error>
Source§impl ObjectFinalize for LinearAttention
impl ObjectFinalize for LinearAttention
Source§impl ToNapiValue for LinearAttention
impl ToNapiValue for LinearAttention
Source§unsafe fn to_napi_value(
env: napi_env,
val: LinearAttention,
) -> Result<napi_value>
unsafe fn to_napi_value( env: napi_env, val: LinearAttention, ) -> Result<napi_value>
Safety Read more
Source§impl TypeName for &LinearAttention
impl TypeName for &LinearAttention
Source§impl TypeName for &mut LinearAttention
impl TypeName for &mut LinearAttention
Source§impl TypeName for LinearAttention
impl TypeName for LinearAttention
Source§impl ValidateNapiValue for &LinearAttention
impl ValidateNapiValue for &LinearAttention
Source§unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
Safety Read more
Source§impl ValidateNapiValue for &mut LinearAttention
impl ValidateNapiValue for &mut LinearAttention
Source§unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
Safety Read more
Auto Trait Implementations§
impl Freeze for LinearAttention
impl RefUnwindSafe for LinearAttention
impl Send for LinearAttention
impl Sync for LinearAttention
impl Unpin for LinearAttention
impl UnsafeUnpin for LinearAttention
impl UnwindSafe for LinearAttention
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