use std::collections::HashMap;
#[derive(Debug, Clone)]
pub struct AdaptiveQuantConfig {
pub enable_ml_prediction: bool,
pub enable_quality_assessment: bool,
pub enable_pattern_recognition: bool,
pub update_frequency: usize,
pub quality_tolerance: f32,
pub performance_weight: f32,
pub energy_weight: f32,
pub accuracy_weight: f32,
pub max_adaptation_rate: f32,
}
impl Default for AdaptiveQuantConfig {
fn default() -> Self {
Self {
enable_ml_prediction: true,
enable_quality_assessment: true,
enable_pattern_recognition: true,
update_frequency: 100,
quality_tolerance: 0.02,
performance_weight: 0.3,
energy_weight: 0.3,
accuracy_weight: 0.4,
max_adaptation_rate: 0.1,
}
}
}
#[derive(Debug, Clone)]
pub struct QuantizationParameters {
pub scale: f32,
pub zero_point: i32,
pub bit_width: u8,
pub scheme: String,
}
impl Default for QuantizationParameters {
fn default() -> Self {
Self {
scale: 1.0,
zero_point: 0,
bit_width: 8,
scheme: "symmetric".to_string(),
}
}
}
#[derive(Debug, Clone)]
pub struct OptimizationTarget {
pub target_accuracy: f32,
pub target_performance: f32,
pub target_energy_efficiency: f32,
pub weights: [f32; 3],
}
impl Default for OptimizationTarget {
fn default() -> Self {
Self {
target_accuracy: 0.95,
target_performance: 1000.0,
target_energy_efficiency: 0.8,
weights: [0.4, 0.3, 0.3], }
}
}
#[derive(Debug, Clone)]
pub struct ConstraintHandler {
pub hardware_constraints: HardwareConstraints,
pub quality_constraints: QualityConstraints,
pub performance_constraints: PerformanceConstraints,
}
impl Default for ConstraintHandler {
fn default() -> Self {
Self {
hardware_constraints: HardwareConstraints::default(),
quality_constraints: QualityConstraints::default(),
performance_constraints: PerformanceConstraints::default(),
}
}
}
#[derive(Debug, Clone)]
pub struct HardwareConstraints {
pub supported_bit_widths: Vec<u8>,
pub max_memory_bandwidth: f32,
pub simd_width: usize,
pub cache_sizes: [usize; 3], }
impl Default for HardwareConstraints {
fn default() -> Self {
Self {
supported_bit_widths: vec![4, 8, 16],
max_memory_bandwidth: 1000.0, simd_width: 256, cache_sizes: [32 * 1024, 256 * 1024, 8 * 1024 * 1024], }
}
}
#[derive(Debug, Clone)]
pub struct QualityConstraints {
pub min_snr: f32,
pub max_mse: f32,
pub min_perceptual_quality: f32,
}
impl Default for QualityConstraints {
fn default() -> Self {
Self {
min_snr: 20.0,
max_mse: 0.01,
min_perceptual_quality: 0.8,
}
}
}
#[derive(Debug, Clone)]
pub struct PerformanceConstraints {
pub max_latency: f32,
pub min_throughput: f32,
pub max_energy: f32,
}
impl Default for PerformanceConstraints {
fn default() -> Self {
Self {
max_latency: 10.0, min_throughput: 100.0, max_energy: 50.0, }
}
}
#[derive(Debug, Clone)]
pub struct AnomalyThresholds {
pub snr_threshold: f32,
pub mse_threshold: f32,
pub perceptual_threshold: f32,
}
impl Default for AnomalyThresholds {
fn default() -> Self {
Self {
snr_threshold: -5.0, mse_threshold: 2.0, perceptual_threshold: -0.1, }
}
}
#[derive(Debug, Clone)]
pub struct PerformanceProfile {
pub avg_execution_time: f32,
pub memory_usage: f32,
pub energy_consumption: f32,
pub cache_efficiency: f32,
}
impl Default for PerformanceProfile {
fn default() -> Self {
Self {
avg_execution_time: 1.0, memory_usage: 100.0, energy_consumption: 10.0, cache_efficiency: 0.8, }
}
}
#[derive(Debug, Clone)]
pub struct FeatureExtractor {
pub enable_statistical: bool,
pub enable_spectral: bool,
pub enable_spatial: bool,
#[allow(dead_code)]
pub(crate) feature_cache: HashMap<String, Vec<f32>>,
}
impl Default for FeatureExtractor {
fn default() -> Self {
Self {
enable_statistical: true,
enable_spectral: true,
enable_spatial: true,
feature_cache: HashMap::new(),
}
}
}
impl FeatureExtractor {
pub fn new() -> Self {
Self::default()
}
}