Enforce tensor structure when aggregating multiple imatrix files

This commit is contained in:
Ed Addario 2025-11-17 14:46:21 +00:00
parent a2b86d7fd9
commit 658c6a8303
No known key found for this signature in database
GPG Key ID: E7875815A3230993
1 changed files with 10 additions and 3 deletions

View File

@ -1043,15 +1043,22 @@ bool IMatrixCollector::load_imatrix(const char * file_name) {
int64_t nval = ggml_nelements(in_sum2);
if (e.values.empty()) {
e.values.resize(nval, 0.0f);
if (in_sum != nullptr) {
e.activations.resize(nval, 0.0f);
}
} else if ((size_t) nval != e.values.size()) {
LOG_ERR("%s: mismatched sums size for %s: %zu != %zu\n", __func__, name.c_str(), (size_t) nval, e.values.size());
gguf_free(ctx_gguf);
ggml_free(ctx);
return false;
}
if (in_sum != nullptr) {
if (e.activations.empty()) {
e.activations.resize(nval, 0.0f);
} else if ((size_t) nval != e.activations.size()) {
LOG_ERR("%s: mismatched activations size for %s: %zu != %zu\n", __func__, name.c_str(), (size_t) nval, e.activations.size());
gguf_free(ctx_gguf);
ggml_free(ctx);
return false;
}
}
int64_t ncounts = ggml_nelements(counts);
if (e.counts.empty()) {