pub struct Config {
pub bits: u8,
pub per_channel: bool,
pub excluded_layers: Vec<String>,
pub min_elements: usize,
pub models: Vec<ModelConfig>,
pub batch: Option<BatchConfig>,
}Expand description
Top-level quantization configuration.
Can be loaded from a YAML or TOML file with Config::from_file.
Fields§
§bits: u8Default bit width (4 or 8). Defaults to 8.
per_channel: boolDefault per-channel setting. Defaults to false.
excluded_layers: Vec<String>Layer names to exclude from quantization globally.
min_elements: usizeMinimum number of elements a tensor must have to be quantized. Tensors smaller than this are kept in FP32. Defaults to 0 (no minimum).
models: Vec<ModelConfig>Per-model configuration overrides.
batch: Option<BatchConfig>Batch processing configuration.
Implementations§
Source§impl Config
impl Config
Sourcepub fn from_file(path: impl AsRef<Path>) -> Result<Self>
pub fn from_file(path: impl AsRef<Path>) -> Result<Self>
Load a config from a YAML or TOML file (auto-detected by extension).
§Errors
Returns QuantizeError::Config on I/O, parse, or unsupported format errors.
Sourcepub fn validate(&self) -> Result<()>
pub fn validate(&self) -> Result<()>
Validate the configuration (bits values, non-empty paths).
§Errors
Returns QuantizeError::Config if any field is invalid.
Sourcepub fn get_bits(&self, model: &ModelConfig) -> u8
pub fn get_bits(&self, model: &ModelConfig) -> u8
Effective bit width for a model (model override or global default).
Sourcepub fn get_per_channel(&self, model: &ModelConfig) -> bool
pub fn get_per_channel(&self, model: &ModelConfig) -> bool
Effective per-channel setting for a model (model override or global default).
Sourcepub fn get_excluded_layers(&self, model: &ModelConfig) -> Vec<String>
pub fn get_excluded_layers(&self, model: &ModelConfig) -> Vec<String>
Effective excluded-layers list: global list merged with model-level list.
Sourcepub fn get_min_elements(&self, model: &ModelConfig) -> usize
pub fn get_min_elements(&self, model: &ModelConfig) -> usize
Effective min-elements threshold for a model.
Sourcepub fn get_layer_bits(&self, model: &ModelConfig) -> HashMap<String, u8>
pub fn get_layer_bits(&self, model: &ModelConfig) -> HashMap<String, u8>
Effective per-layer bit-width overrides for a model.
Layer names are model-specific so there is no global map to merge;
this simply returns the model’s own layer_bits map.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnsafeUnpin for Config
impl UnwindSafe for Config
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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