quantize : terminate on errors + trace logs
ggml-ci
This commit is contained in:
parent
822caa46a1
commit
a054283c0f
1 changed files with 10 additions and 6 deletions
|
@ -116,13 +116,13 @@ static void load_imatrix(const std::string & imatrix_file, std::unordered_map<st
|
||||||
std::ifstream in(imatrix_file.c_str(), std::ios::binary);
|
std::ifstream in(imatrix_file.c_str(), std::ios::binary);
|
||||||
if (!in) {
|
if (!in) {
|
||||||
printf("%s: failed to open %s\n",__func__, imatrix_file.c_str());
|
printf("%s: failed to open %s\n",__func__, imatrix_file.c_str());
|
||||||
return;
|
exit(1);
|
||||||
}
|
}
|
||||||
int n_entries;
|
int n_entries;
|
||||||
in.read((char *)&n_entries, sizeof(n_entries));
|
in.read((char *)&n_entries, sizeof(n_entries));
|
||||||
if (in.fail() || n_entries < 1) {
|
if (in.fail() || n_entries < 1) {
|
||||||
printf("%s: no data in file %s\n", __func__, imatrix_file.c_str());
|
printf("%s: no data in file %s\n", __func__, imatrix_file.c_str());
|
||||||
return;
|
exit(1);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < n_entries; ++i) {
|
for (int i = 0; i < n_entries; ++i) {
|
||||||
int len; in.read((char *)&len, sizeof(len));
|
int len; in.read((char *)&len, sizeof(len));
|
||||||
|
@ -130,11 +130,11 @@ static void load_imatrix(const std::string & imatrix_file, std::unordered_map<st
|
||||||
in.read((char *)name_as_vec.data(), len);
|
in.read((char *)name_as_vec.data(), len);
|
||||||
if (in.fail()) {
|
if (in.fail()) {
|
||||||
printf("%s: failed reading name for entry %d from %s\n", __func__, i+1, imatrix_file.c_str());
|
printf("%s: failed reading name for entry %d from %s\n", __func__, i+1, imatrix_file.c_str());
|
||||||
return;
|
exit(1);
|
||||||
}
|
}
|
||||||
name_as_vec[len] = 0;
|
name_as_vec[len] = 0;
|
||||||
std::string name{name_as_vec.data()};
|
std::string name{name_as_vec.data()};
|
||||||
auto & e = imatrix_data[std::move(name)];
|
auto & e = imatrix_data[name];
|
||||||
int ncall;
|
int ncall;
|
||||||
in.read((char *)&ncall, sizeof(ncall));
|
in.read((char *)&ncall, sizeof(ncall));
|
||||||
int nval;
|
int nval;
|
||||||
|
@ -142,18 +142,22 @@ static void load_imatrix(const std::string & imatrix_file, std::unordered_map<st
|
||||||
if (in.fail() || nval < 1) {
|
if (in.fail() || nval < 1) {
|
||||||
printf("%s: failed reading number of values for entry %d\n", __func__, i);
|
printf("%s: failed reading number of values for entry %d\n", __func__, i);
|
||||||
imatrix_data = {};
|
imatrix_data = {};
|
||||||
return;
|
exit(1);
|
||||||
}
|
}
|
||||||
e.resize(nval);
|
e.resize(nval);
|
||||||
in.read((char *)e.data(), nval*sizeof(float));
|
in.read((char *)e.data(), nval*sizeof(float));
|
||||||
if (in.fail()) {
|
if (in.fail()) {
|
||||||
printf("%s: failed reading data for entry %d\n", __func__, i);
|
printf("%s: failed reading data for entry %d\n", __func__, i);
|
||||||
imatrix_data = {};
|
imatrix_data = {};
|
||||||
return;
|
exit(1);
|
||||||
}
|
}
|
||||||
if (ncall > 0) {
|
if (ncall > 0) {
|
||||||
for (auto& v : e) v /= ncall;
|
for (auto& v : e) v /= ncall;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getenv("LLAMA_TRACE")) {
|
||||||
|
printf("%s: loaded data (size = %6d, ncall = %6d) for '%s'\n", __func__, int(e.size()), ncall, name.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
printf("%s: loaded %d importance matrix entries from %s\n", __func__, int(imatrix_data.size()), imatrix_file.c_str());
|
printf("%s: loaded %d importance matrix entries from %s\n", __func__, int(imatrix_data.size()), imatrix_file.c_str());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue