From 34290a479c6af4ea639b90f2b9916e537136409a Mon Sep 17 00:00:00 2001 From: Danny Chen Date: Thu, 6 Jun 2024 16:03:22 +0000 Subject: [PATCH] Changed GetPostprocessedLattice to scale a copy of the input lattice so that the scaling matrix isn't applied multiple times --- src/cudadecoder/lattice-postprocessor.cc | 3 ++- src/cudadecoder/lattice-postprocessor.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cudadecoder/lattice-postprocessor.cc b/src/cudadecoder/lattice-postprocessor.cc index 752e8ae90b7..69fa8a3cc82 100644 --- a/src/cudadecoder/lattice-postprocessor.cc +++ b/src/cudadecoder/lattice-postprocessor.cc @@ -53,12 +53,13 @@ void LatticePostprocessor::ApplyConfig() { } bool LatticePostprocessor::GetPostprocessedLattice( - CompactLattice &clat, CompactLattice *out_clat) const { + const CompactLattice &clat_const, CompactLattice *out_clat) const { // Nothing to do for empty lattice if (clat.NumStates() == 0) return true; bool ok = true; // Scale lattice + CompactLattice clat = clat_const; if (use_lattice_scale_) fst::ScaleLattice(lattice_scales_, &clat); // Word insertion penalty diff --git a/src/cudadecoder/lattice-postprocessor.h b/src/cudadecoder/lattice-postprocessor.h index b85839132db..89247f47ce3 100644 --- a/src/cudadecoder/lattice-postprocessor.h +++ b/src/cudadecoder/lattice-postprocessor.h @@ -90,7 +90,7 @@ class LatticePostprocessor { LatticePostprocessor(const LatticePostprocessorConfig &config); void ApplyConfig(); bool GetCTM(CompactLattice &clat, CTMResult *ctm_result) const; - bool GetPostprocessedLattice(CompactLattice &clat, + bool GetPostprocessedLattice(const CompactLattice &clat_const, CompactLattice *out_clat) const; std::vector GetNBestList(CompactLattice &clat) const;