Skip to content

Commit

Permalink
Tweak quantize write to still do one memory access
Browse files Browse the repository at this point in the history
  • Loading branch information
kpu committed Aug 29, 2020
1 parent c63e9d9 commit 0dd7a8f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lm/quantize.hh
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,16 @@ class SeparatelyQuantize {
float Rest() const { return Prob(); }

void Write(float prob, float backoff) const {
util::WriteInt25(address_.base, address_.offset + BackoffBins().Bits(), ProbBins().Bits(), ProbBins().EncodeProb(prob));
util::WriteInt25(address_.base, address_.offset, BackoffBins().Bits(), BackoffBins().EncodeBackoff(backoff));
uint64_t prob_encoded = ProbBins().EncodeProb(prob);
uint64_t backoff_encoded = BackoffBins().EncodeBackoff(backoff);
#if BYTE_ORDER == LITTLE_ENDIAN
prob_encoded
#elif BYTE_ORDER == BIG_ENDIAN
backoff_encoded
#endif
<<= BackoffBins().Bits();
util::WriteInt57(address_.base, address_.offset, ProbBins().Bits() + BackoffBins().Bits(),
prob_encoded | backoff_encoded);
}

private:
Expand Down

0 comments on commit 0dd7a8f

Please sign in to comment.