Skip to content

Commit

Permalink
fix: avoid underflow in GMM computation
Browse files Browse the repository at this point in the history
MIPS, among others, will *not* fail gracefully here (should fix #252, #199)
  • Loading branch information
dhdaines committed Sep 28, 2022
1 parent e4fcf58 commit fbd61be
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/ptm_mgau.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ eval_topn(ptm_mgau_t *s, int cb, int feat, mfcc_t *z)
obs += 4;
mean += 4;
}
insertion_sort_topn(topn, i, (int32)d);
if (d < (mfcc_t)INT_MIN) /* Redundant if FIXED_POINT */
insertion_sort_topn(topn, i, INT_MIN);
else
insertion_sort_topn(topn, i, (int32)d);
}

return topn[0].score;
Expand Down Expand Up @@ -213,7 +216,10 @@ eval_cb(ptm_mgau_t *s, int cb, int feat, mfcc_t *z)
}
if (i < s->max_topn)
continue; /* already there. Don't insert */
insertion_sort_cb(&cur, worst, best, cw, (int32)d);
if (d < (mfcc_t)INT_MIN) /* Redundant if FIXED_POINT */
insertion_sort_cb(&cur, worst, best, cw, INT_MIN);
else
insertion_sort_cb(&cur, worst, best, cw, (int32)d);
}

return best->score;
Expand Down Expand Up @@ -271,7 +277,6 @@ ptm_mgau_codebook_norm(ptm_mgau_t *s, mfcc_t **z, int frame)
if (norm < s->f->topn[i][j][0].score >> SENSCR_SHIFT)
norm = s->f->topn[i][j][0].score >> SENSCR_SHIFT;
}
assert(norm != WORST_SCORE);
for (i = 0; i < s->g->n_mgau; ++i) {
int32 k;
if (bitvec_is_clear(s->f->mgau_active, i))
Expand Down

0 comments on commit fbd61be

Please sign in to comment.