pub struct WasmMicroLoRA { /* private fields */ }Expand description
WASM-exposed MicroLoRA engine
Implementations§
Source§impl WasmMicroLoRA
impl WasmMicroLoRA
Sourcepub fn new(
dim: Option<usize>,
alpha: Option<f32>,
learning_rate: Option<f32>,
) -> Self
pub fn new( dim: Option<usize>, alpha: Option<f32>, learning_rate: Option<f32>, ) -> Self
Create a new MicroLoRA engine
@param dim - Embedding dimension (default 256, max 256) @param alpha - Scaling factor (default 0.1) @param learning_rate - Learning rate (default 0.01)
Sourcepub fn get_input_ptr(&mut self) -> *mut f32
pub fn get_input_ptr(&mut self) -> *mut f32
Get pointer to input buffer for direct memory access
Sourcepub fn get_output_ptr(&self) -> *const f32
pub fn get_output_ptr(&self) -> *const f32
Get pointer to output buffer for direct memory access
Sourcepub fn forward(&mut self)
pub fn forward(&mut self)
Forward pass using internal buffers (zero-allocation)
Write input to get_input_ptr(), call forward(), read from get_output_ptr()
Sourcepub fn forward_array(&mut self, input: &[f32]) -> Vec<f32>
pub fn forward_array(&mut self, input: &[f32]) -> Vec<f32>
Forward pass with typed array input (allocates output)
Sourcepub fn adapt_array(&mut self, gradient: &[f32])
pub fn adapt_array(&mut self, gradient: &[f32])
Adapt with typed array gradient
Sourcepub fn adapt_with_reward(&mut self, improvement: f32)
pub fn adapt_with_reward(&mut self, improvement: f32)
Adapt with improvement reward using input buffer as gradient
Sourcepub fn forward_count(&self) -> u64
pub fn forward_count(&self) -> u64
Get forward pass count
Sourcepub fn adapt_count(&self) -> u64
pub fn adapt_count(&self) -> u64
Get adaptation count
Sourcepub fn delta_norm(&self) -> f32
pub fn delta_norm(&self) -> f32
Get delta norm (weight change magnitude)
Sourcepub fn param_count(&self) -> usize
pub fn param_count(&self) -> usize
Get parameter count
Trait Implementations§
Source§impl From<WasmMicroLoRA> for JsValue
impl From<WasmMicroLoRA> for JsValue
Source§fn from(value: WasmMicroLoRA) -> Self
fn from(value: WasmMicroLoRA) -> Self
Converts to this type from the input type.
Source§impl FromWasmAbi for WasmMicroLoRA
impl FromWasmAbi for WasmMicroLoRA
Source§impl IntoWasmAbi for WasmMicroLoRA
impl IntoWasmAbi for WasmMicroLoRA
Source§impl LongRefFromWasmAbi for WasmMicroLoRA
impl LongRefFromWasmAbi for WasmMicroLoRA
Source§type Abi = WasmPtr<WasmRefCell<WasmMicroLoRA>>
type Abi = WasmPtr<WasmRefCell<WasmMicroLoRA>>
Same as
RefFromWasmAbi::AbiSource§type Anchor = RcRef<WasmMicroLoRA>
type Anchor = RcRef<WasmMicroLoRA>
Same as
RefFromWasmAbi::AnchorSource§unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor
unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor
Same as
RefFromWasmAbi::ref_from_abiSource§impl OptionFromWasmAbi for WasmMicroLoRA
impl OptionFromWasmAbi for WasmMicroLoRA
Source§impl OptionIntoWasmAbi for WasmMicroLoRA
impl OptionIntoWasmAbi for WasmMicroLoRA
Source§impl RefFromWasmAbi for WasmMicroLoRA
impl RefFromWasmAbi for WasmMicroLoRA
Source§type Abi = WasmPtr<WasmRefCell<WasmMicroLoRA>>
type Abi = WasmPtr<WasmRefCell<WasmMicroLoRA>>
The Wasm ABI type references to
Self are recovered from.Source§type Anchor = RcRef<WasmMicroLoRA>
type Anchor = RcRef<WasmMicroLoRA>
The type that holds the reference to
Self for the duration of the
invocation of the function that has an &Self parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.Source§impl RefMutFromWasmAbi for WasmMicroLoRA
impl RefMutFromWasmAbi for WasmMicroLoRA
Source§type Abi = WasmPtr<WasmRefCell<WasmMicroLoRA>>
type Abi = WasmPtr<WasmRefCell<WasmMicroLoRA>>
Same as
RefFromWasmAbi::AbiSource§type Anchor = RcRefMut<WasmMicroLoRA>
type Anchor = RcRefMut<WasmMicroLoRA>
Same as
RefFromWasmAbi::AnchorSource§unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor
unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor
Same as
RefFromWasmAbi::ref_from_abiimpl SupportsConstructor for WasmMicroLoRA
impl SupportsInstanceProperty for WasmMicroLoRA
impl SupportsStaticProperty for WasmMicroLoRA
Source§impl TryFromJsValue for WasmMicroLoRA
impl TryFromJsValue for WasmMicroLoRA
Source§impl VectorFromWasmAbi for WasmMicroLoRA
impl VectorFromWasmAbi for WasmMicroLoRA
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[WasmMicroLoRA]>
Source§impl VectorIntoWasmAbi for WasmMicroLoRA
impl VectorIntoWasmAbi for WasmMicroLoRA
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[WasmMicroLoRA]>) -> Self::Abi
Source§impl WasmDescribeVector for WasmMicroLoRA
impl WasmDescribeVector for WasmMicroLoRA
Auto Trait Implementations§
impl Freeze for WasmMicroLoRA
impl RefUnwindSafe for WasmMicroLoRA
impl Send for WasmMicroLoRA
impl Sync for WasmMicroLoRA
impl Unpin for WasmMicroLoRA
impl UnsafeUnpin for WasmMicroLoRA
impl UnwindSafe for WasmMicroLoRA
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> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
Same as
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
Same as
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.