Skip to content

Commit

Permalink
[src] Speed optimization for decoders (call templates properly) (kald…
Browse files Browse the repository at this point in the history
  • Loading branch information
Bar-BY authored and danpovey committed Oct 9, 2019
1 parent 8a1be79 commit a4de025
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 19 deletions.
5 changes: 1 addition & 4 deletions src/decoder/faster-decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ void FasterDecoder::InitDecoding() {

void FasterDecoder::Decode(DecodableInterface *decodable) {
InitDecoding();
while (!decodable->IsLastFrame(num_frames_decoded_ - 1)) {
double weight_cutoff = ProcessEmitting(decodable);
ProcessNonemitting(weight_cutoff);
}
AdvanceDecoding(decodable);
}

void FasterDecoder::AdvanceDecoding(DecodableInterface *decodable,
Expand Down
9 changes: 1 addition & 8 deletions src/decoder/lattice-faster-decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,10 @@ void LatticeFasterDecoderTpl<FST, Token>::InitDecoding() {
template <typename FST, typename Token>
bool LatticeFasterDecoderTpl<FST, Token>::Decode(DecodableInterface *decodable) {
InitDecoding();

// We use 1-based indexing for frames in this decoder (if you view it in
// terms of features), but note that the decodable object uses zero-based
// numbering, which we have to correct for when we call it.

while (!decodable->IsLastFrame(NumFramesDecoded() - 1)) {
if (NumFramesDecoded() % config_.prune_interval == 0)
PruneActiveTokens(config_.lattice_beam * config_.prune_scale);
BaseFloat cost_cutoff = ProcessEmitting(decodable);
ProcessNonemitting(cost_cutoff);
}
AdvanceDecoding(decodable);
FinalizeDecoding();

// Returns true if we have any kind of traceback available (not necessarily
Expand Down
8 changes: 1 addition & 7 deletions src/decoder/simple-decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,7 @@ SimpleDecoder::~SimpleDecoder() {

bool SimpleDecoder::Decode(DecodableInterface *decodable) {
InitDecoding();
while( !decodable->IsLastFrame(num_frames_decoded_ - 1)) {
ClearToks(prev_toks_);
cur_toks_.swap(prev_toks_);
ProcessEmitting(decodable);
ProcessNonemitting();
PruneToks(beam_, &cur_toks_);
}
AdvanceDecoding(decodable);
return (!cur_toks_.empty());
}

Expand Down

0 comments on commit a4de025

Please sign in to comment.