Update aggregated statistic report layout

This commit is contained in:
Ed Addario 2025-08-03 16:38:02 +01:00
parent a6155a8125
commit 2117c4e54b
No known key found for this signature in database
GPG Key ID: E7875815A3230993
1 changed files with 19 additions and 27 deletions

View File

@ -1324,50 +1324,42 @@ static bool show_statistics(const common_params & params) {
const float w_sum = tstat.elements * tstat.sum_values; const float w_sum = tstat.elements * tstat.sum_values;
const float w_zd = tstat.elements * tstat.zd_score; const float w_zd = tstat.elements * tstat.zd_score;
const float w_cossim = tstat.elements * tstat.cossim;
if (ws.find(blk) != ws.end()) { if (ws.find(blk) != ws.end()) {
ws[blk].w_sum += w_sum; ws[blk].w_sum += w_sum;
ws[blk].w_zd += w_zd; ws[blk].w_zd += w_zd;
ws[blk].w_cossim += w_cossim;
ws[blk].n += tstat.elements; ws[blk].n += tstat.elements;
} else { } else {
weighted_stats temp_ws; weighted_stats temp_ws;
temp_ws.w_sum = w_sum; temp_ws.w_sum = w_sum;
temp_ws.w_zd = w_zd; temp_ws.w_zd = w_zd;
temp_ws.w_cossim = w_cossim;
temp_ws.n = tstat.elements; temp_ws.n = tstat.elements;
ws[blk] = temp_ws; ws[blk] = temp_ws;
} }
} }
const int layers = std::count_if(ws.begin(), ws.end(), [](const auto & kv) { return kv.first >= 0; }); std::map<int, float> layer_cossim;
LOG_INF("\nComputing weighted average statistics per layer (%d layers)\n", layers); compute_layer_statistics(ts, layer_cossim, g_collector.get_mstats());
const auto layers = std::count_if(ws.begin(), ws.end(), [](const auto & kv) { return kv.first >= 0; });
LOG_INF("\nComputing aggregated statistics per layer (%ld layers)\n", layers);
LOG_INF("\n%6s\t%16s\t%7s\t%11s\n", LOG_INF("\n%6s\t%16s\t%7s\t%11s\n",
"Layer", "Layer",
tensor_calc_mode == 1 ? "μL₂ Norm" : "μΣ(Act²)", tensor_calc_mode == 1 ? "L₂ Norm" : "Σ(Act²)",
"μZD", "ZD",
"μCosSim"); "CosSim");
LOG_INF("============================================\n"); LOG_INF("============================================\n");
for (const auto & [first, second] : ws) { for (const auto & [layer, stats] : ws) {
const auto & layer = first; if (layer < 0 || stats.n == 0) continue;
const auto & stats = second; const float w_sum = stats.w_sum / stats.n;
const float w_zd = stats.w_zd / stats.n;
if (stats.n == 0) { const auto lcs = layer_cossim.find(layer);
continue; const float cossim = (lcs != layer_cossim.end()) ? lcs->second : 0.0f;
} LOG_INF("%5d\t%11.2f\t%6.2f%%\t%10.4f\n",
layer,
if (layer >= 0) { w_sum,
const float w_sum = stats.w_sum / stats.n; 100.0f * w_zd,
const float w_zd = stats.w_zd / stats.n; cossim);
const float w_cossim = stats.w_cossim / stats.n;
LOG_INF("%5d\t%11.2f\t%6.2f%%\t%10.4f\n",
layer,
w_sum,
100.0f * w_zd,
w_cossim);
}
} }
LOG_INF("\n"); LOG_INF("\n");