Skip to content

Commit

Permalink
Fix LogAdd (#316)
Browse files Browse the repository at this point in the history
Using 0 as the initial value,  should not perform addition when both values are 0
  • Loading branch information
kamirdin authored Sep 18, 2023
1 parent c471423 commit 5ca0ff8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sherpa-onnx/csrc/hypothesis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ void Hypotheses::Add(Hypothesis hyp) {
} else {
it->second.log_prob = LogAdd<double>()(it->second.log_prob, hyp.log_prob);

it->second.lm_log_prob =
if (it->second.lm_log_prob != 0 && hyp.lm_log_prob != 0){
it->second.lm_log_prob =
LogAdd<double>()(it->second.lm_log_prob, hyp.lm_log_prob);
}
}
}

Expand Down

0 comments on commit 5ca0ff8

Please sign in to comment.