use serde_json::Value;
use crate::types::DiffResult;
mod distributions;
mod flow;
mod magnitudes;
mod statistics;
mod types;
use distributions::analyze_gradient_distributions;
use flow::analyze_gradient_flow;
use magnitudes::analyze_gradient_magnitudes;
pub fn analyze_gradient_patterns(
old_model: &Value,
new_model: &Value,
results: &mut Vec<DiffResult>,
) {
if let (Value::Object(old_obj), Value::Object(new_obj)) = (old_model, new_model) {
if let Some((old_mag, new_mag)) = analyze_gradient_magnitudes(old_obj, new_obj) {
results.push(DiffResult::ModelArchitectureChanged(
"gradient_magnitudes".to_string(),
old_mag,
new_mag,
));
}
if let Some((old_dist, new_dist)) = analyze_gradient_distributions(old_obj, new_obj) {
results.push(DiffResult::ModelArchitectureChanged(
"gradient_distributions".to_string(),
old_dist,
new_dist,
));
}
if let Some((old_flow, new_flow)) = analyze_gradient_flow(old_obj, new_obj) {
results.push(DiffResult::ModelArchitectureChanged(
"gradient_flow".to_string(),
old_flow,
new_flow,
));
}
}
}