save partial imatrix

This commit is contained in:
Sigbjørn Skjæret 2024-06-13 01:02:22 +02:00 committed by GitHub
parent 963552903f
commit 0e36739915
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -250,8 +250,7 @@ void IMatrixCollector::save_imatrix(int ncall) const {
} }
if (n_zeros > 0) { if (n_zeros > 0) {
fprintf(stderr, "%s: entry '%40s' has partial data (%.2f%%) - skipping\n", __func__, kv.first.c_str(), 100.0f * (n_all - n_zeros) / n_all); fprintf(stderr, "%s: entry '%40s' has partial data (%.2f%%)\n", __func__, kv.first.c_str(), 100.0f * (n_all - n_zeros) / n_all);
continue;
} }
n_entries++; n_entries++;
@ -275,7 +274,7 @@ void IMatrixCollector::save_imatrix(int ncall) const {
if (nval > 0) { if (nval > 0) {
std::vector<float> tmp(nval); std::vector<float> tmp(nval);
for (int i = 0; i < nval; i++) { for (int i = 0; i < nval; i++) {
tmp[i] = (stat.values[i] / static_cast<float>(stat.counts[i])) * static_cast<float>(stat.ncall); tmp[i] = stat.counts[i] ? (stat.values[i] / static_cast<float>(stat.counts[i])) * static_cast<float>(stat.ncall) : 0.0f;
} }
out.write((const char*)tmp.data(), nval*sizeof(float)); out.write((const char*)tmp.data(), nval*sizeof(float));
} }