pub struct WebQuantizer { /* private fields */ }Expand description
Web-optimized quantizer with runtime adaptation
Implementations§
Source§impl WebQuantizer
impl WebQuantizer
Sourcepub fn new(config: QuantizationConfig) -> Self
pub fn new(config: QuantizationConfig) -> Self
Create a new web quantizer
Sourcepub fn quantize(&self, data: &[f32]) -> Result<Vec<f32>, JsValue>
pub fn quantize(&self, data: &[f32]) -> Result<Vec<f32>, JsValue>
Quantize tensor data using the configured strategy
Sourcepub fn get_stats(
&self,
original_data: &[f32],
quantized_data: &[f32],
) -> QuantizationStats
pub fn get_stats( &self, original_data: &[f32], quantized_data: &[f32], ) -> QuantizationStats
Get quantization statistics
Sourcepub fn should_quantize(&self, model_size_bytes: usize) -> bool
pub fn should_quantize(&self, model_size_bytes: usize) -> bool
Check if a model should be quantized based on size
Sourcepub fn quantize_model(
&self,
model_data: &[u8],
) -> Result<QuantizationResult, JsValue>
pub fn quantize_model( &self, model_data: &[u8], ) -> Result<QuantizationResult, JsValue>
Quantize model data
Sourcepub fn get_recommended_settings(
&self,
model_size_bytes: usize,
) -> QuantizationConfig
pub fn get_recommended_settings( &self, model_size_bytes: usize, ) -> QuantizationConfig
Get recommended quantization settings for a given model size
Trait Implementations§
Source§impl From<WebQuantizer> for JsValue
impl From<WebQuantizer> for JsValue
Source§fn from(value: WebQuantizer) -> Self
fn from(value: WebQuantizer) -> Self
Converts to this type from the input type.
Source§impl FromWasmAbi for WebQuantizer
impl FromWasmAbi for WebQuantizer
Source§impl IntoWasmAbi for WebQuantizer
impl IntoWasmAbi for WebQuantizer
Source§impl LongRefFromWasmAbi for WebQuantizer
impl LongRefFromWasmAbi for WebQuantizer
Source§impl OptionFromWasmAbi for WebQuantizer
impl OptionFromWasmAbi for WebQuantizer
Source§impl OptionIntoWasmAbi for WebQuantizer
impl OptionIntoWasmAbi for WebQuantizer
Source§impl RefFromWasmAbi for WebQuantizer
impl RefFromWasmAbi for WebQuantizer
Source§type Anchor = RcRef<WebQuantizer>
type Anchor = RcRef<WebQuantizer>
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 WebQuantizer
impl RefMutFromWasmAbi for WebQuantizer
Source§impl TryFromJsValue for WebQuantizer
impl TryFromJsValue for WebQuantizer
Source§impl VectorFromWasmAbi for WebQuantizer
impl VectorFromWasmAbi for WebQuantizer
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[WebQuantizer]>
Source§impl VectorIntoWasmAbi for WebQuantizer
impl VectorIntoWasmAbi for WebQuantizer
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[WebQuantizer]>) -> Self::Abi
Source§impl WasmDescribeVector for WebQuantizer
impl WasmDescribeVector for WebQuantizer
impl SupportsConstructor for WebQuantizer
impl SupportsInstanceProperty for WebQuantizer
impl SupportsStaticProperty for WebQuantizer
Auto Trait Implementations§
impl Freeze for WebQuantizer
impl RefUnwindSafe for WebQuantizer
impl Send for WebQuantizer
impl Sync for WebQuantizer
impl Unpin for WebQuantizer
impl UnsafeUnpin for WebQuantizer
impl UnwindSafe for WebQuantizer
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.