diff options
author | slaren <slarengh@gmail.com> | 2024-06-07 08:01:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-07 09:01:29 +0300 |
commit | c9ee7118d5644dd3df70ea6878b36a9761616aab (patch) | |
tree | 96464f12935cf86174a4e47ba184236ee771905a /examples | |
parent | ee459f40f65810a810151b24eba5b8bd174ceffe (diff) |
check for nans in imatrix and quantize (#7807)
* imatrix : detect nan/inf values
* quantize : check imatrix for nan/inf values
Diffstat (limited to 'examples')
-rw-r--r-- | examples/imatrix/imatrix.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/examples/imatrix/imatrix.cpp b/examples/imatrix/imatrix.cpp index 38420041..e18f4956 100644 --- a/examples/imatrix/imatrix.cpp +++ b/examples/imatrix/imatrix.cpp @@ -151,6 +151,10 @@ bool IMatrixCollector::collect_imatrix(struct ggml_tensor * t, bool ask, void * for (int j = 0; j < (int)src1->ne[0]; ++j) { e.values[e_start + j] += x[j]*x[j]; e.counts[e_start + j]++; + if (!std::isfinite(e.values[e_start + j])) { + fprintf(stderr, "%f detected in %s\n", e.values[e_start + j], wname.c_str()); + exit(1); + } } } } @@ -183,6 +187,10 @@ bool IMatrixCollector::collect_imatrix(struct ggml_tensor * t, bool ask, void * for (int j = 0; j < (int)src1->ne[0]; ++j) { e.values[j] += x[j]*x[j]; e.counts[j]++; + if (!std::isfinite(e.values[j])) { + fprintf(stderr, "%f detected in %s\n", e.values[j], wname.c_str()); + exit(1); + } } } if (e.ncall > m_last_call) { |