Skip to content

Commit

Permalink
Parallelizing the decoder FST construction.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 673397357
  • Loading branch information
agutkin authored and copybara-github committed Sep 11, 2024
1 parent 7c7c458 commit d2c7cfa
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions nisaba/translit/fst/pairlm_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -993,11 +993,18 @@ StdVectorFst PairLMDecoder::BuildTransliterationFst(
const std::vector<std::string> input_words = absl::StrSplit(
input_line, utf8::Utf8WhitespaceDelimiter(), absl::SkipEmpty());
std::vector<StdVectorFst> translit_fsts(input_words.size());
// TODO: Fix parallelization.
{
ThreadPool pool(max_parallel_tokens_);
pool.StartWorkers();
for (int i = 0; i < input_words.size(); ++i) {
translit_fsts[i] = TransliterateWord(input_words[i], word_k_best,
fst_params);
pool.Schedule([this, i, word_k_best, &translit_fsts, &input_words,
&fst_params] {
translit_fsts[i] = TransliterateWord(input_words[i], word_k_best,
fst_params);
});
}
// Wait until all threads are complete.
}

// Loop through the fsts produced, joining them into a sentence lattice.
for (int i = 0; i < input_words.size(); ++i) {
Expand Down

0 comments on commit d2c7cfa

Please sign in to comment.