|
@@ -54,10 +54,14 @@ void ModifiedBeamSearchDecoder::Decode() {
|
|
|
model_->RunEncoder(features, encoder_state_);
|
|
|
|
|
|
Hypotheses cur = std::move(result_.hyps);
|
|
|
- std::vector<Hypothesis> prev;
|
|
|
/* encoder_out_.w == encoder_out_dim, encoder_out_.h == num_frames. */
|
|
|
for (int32_t t = 0; t != encoder_out_.h; ++t) {
|
|
|
- prev = std::move(cur.Vec());
|
|
|
+ std::vector<Hypothesis> prev;
|
|
|
+ for (int32_t i = 0; i != config_.num_active_paths && cur.Size(); ++i) {
|
|
|
+ auto cur_best_hyp = cur.GetMostProbable(true);
|
|
|
+ cur.Remove(cur_best_hyp);
|
|
|
+ prev.push_back(std::move(cur_best_hyp));
|
|
|
+ }
|
|
|
cur.clear();
|
|
|
|
|
|
for (const auto &h : prev) {
|
|
@@ -84,11 +88,6 @@ void ModifiedBeamSearchDecoder::Decode() {
|
|
|
cur.Add(std::move(new_hyp));
|
|
|
}
|
|
|
}
|
|
|
- // prune active_paths
|
|
|
- while (cur.Size() > config_.num_active_paths) {
|
|
|
- auto least_hyp = cur.GetLeastProbable(true);
|
|
|
- cur.Remove(least_hyp);
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
num_processed_ += offset_;
|