@@ -294,7 +294,7 @@ void IMatrixCollector::save_imatrix(int ncall) const {
294294bool IMatrixCollector::load_imatrix (const char * fname) {
295295 std::ifstream in (fname, std::ios::binary);
296296 if (!in) {
297- LOG_ERR (" %s: failed to open %s\n " ,__func__, fname);
297+ LOG_ERR (" %s: failed to open %s\n " , __func__, fname);
298298 return false ;
299299 }
300300 int n_entries;
@@ -308,7 +308,7 @@ bool IMatrixCollector::load_imatrix(const char * fname) {
308308 std::vector<char > name_as_vec (len+1 );
309309 in.read ((char *)name_as_vec.data (), len);
310310 if (in.fail ()) {
311- LOG_ERR (" %s: failed reading name for entry %d from %s\n " ,__func__,i+ 1 , fname);
311+ LOG_ERR (" %s: failed reading name for entry %d from %s\n " , __func__, i + 1 , fname);
312312 return false ;
313313 }
314314 name_as_vec[len] = 0 ;
@@ -319,7 +319,7 @@ bool IMatrixCollector::load_imatrix(const char * fname) {
319319 int nval;
320320 in.read ((char *)&nval, sizeof (nval));
321321 if (in.fail () || nval < 1 ) {
322- LOG_ERR (" %s: failed reading number of values for entry %d\n " ,__func__,i);
322+ LOG_ERR (" %s: failed reading number of values for entry %d\n " , __func__, i);
323323 m_stats = {};
324324 return false ;
325325 }
@@ -332,15 +332,15 @@ bool IMatrixCollector::load_imatrix(const char * fname) {
332332 std::vector<float > tmp (nval);
333333 in.read ((char *)tmp.data (), nval*sizeof (float ));
334334 if (in.fail ()) {
335- LOG_ERR (" %s: failed reading data for entry %d\n " ,__func__,i);
335+ LOG_ERR (" %s: failed reading data for entry %d\n " , __func__, i);
336336 m_stats = {};
337337 return false ;
338338 }
339339
340340 // Recreate the state as expected by save_imatrix(), and corerct for weighted sum.
341- for (int i = 0 ; i < nval; i ++) {
342- e.values [i ] += tmp[i ];
343- e.counts [i ] += ncall;
341+ for (int j = 0 ; j < nval; j ++) {
342+ e.values [j ] += tmp[j ];
343+ e.counts [j ] += ncall;
344344 }
345345 e.ncall += ncall;
346346
@@ -488,12 +488,10 @@ static bool compute_imatrix(llama_context * ctx, const common_params & params) {
488488 logits.reserve ((size_t )n_ctx * n_vocab);
489489 }
490490
491- for (int i = 0 ; i < n_chunk; ++i ) {
492- const int start = i * n_ctx;
491+ for (int ich = 0 ; ich < n_chunk; ++ich ) {
492+ const int start = ich * n_ctx;
493493 const int end = start + n_ctx;
494494
495- std::vector<float > logits;
496-
497495 const auto t_start = std::chrono::high_resolution_clock::now ();
498496
499497 // clear the KV cache
@@ -537,7 +535,7 @@ static bool compute_imatrix(llama_context * ctx, const common_params & params) {
537535
538536 const auto t_end = std::chrono::high_resolution_clock::now ();
539537
540- if (i == 0 ) {
538+ if (ich == 0 ) {
541539 const float t_total = std::chrono::duration<float >(t_end - t_start).count ();
542540 LOG_INF (" %s: %.2f seconds per pass - ETA " , __func__, t_total);
543541 int total_seconds = (int )(t_total * n_chunk);
@@ -555,7 +553,7 @@ static bool compute_imatrix(llama_context * ctx, const common_params & params) {
555553 workers, nll, nll2, logit_history.data () + start + first, prob_history.data () + start + first);
556554 count += n_ctx - first - 1 ;
557555
558- LOG (" [%d]%.4lf," , i + 1 , std::exp (nll / count));
556+ LOG (" [%d]%.4lf," , ich + 1 , std::exp (nll / count));
559557 fflush (stdout);
560558
561559 logits.clear ();
0 commit comments