Fix a segfault with the chop variant of trie in chart decoding

git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@4272 1f5c12ca-751b-0410-a591-d2e778427230
This commit is contained in:
heafield 2011-09-26 20:54:41 +00:00
parent d6b15ff038
commit 41cc547360
3 changed files with 8 additions and 7 deletions

View File

@ -11,6 +11,7 @@
*/
#include <inttypes.h>
#include <assert.h>
#include "lm/model_type.hh"
#include "lm/trie.hh"
@ -78,6 +79,7 @@ class ArrayBhiksha {
util::ReadInt57(base, bit_offset, next_inline_.bits, next_inline_.mask);
out.end = ((end_it - offset_begin_) << next_inline_.bits) |
util::ReadInt57(base, bit_offset + total_bits, next_inline_.bits, next_inline_.mask);
//assert(out.end >= out.begin);
}
void WriteNext(void *base, uint64_t bit_offset, uint64_t index, uint64_t value) {

View File

@ -91,16 +91,14 @@ template <class Quant, class Bhiksha> bool BitPackedMiddle<Quant, Bhiksha>::Find
if (!FindBitPacked(base_, word_mask_, word_bits_, total_bits_, range.begin, range.end, max_vocab_, word, at_pointer)) {
return false;
}
uint64_t index = at_pointer;
pointer = at_pointer;
at_pointer *= total_bits_;
at_pointer += word_bits_;
pointer = at_pointer;
quant_.Read(base_, at_pointer, prob, backoff);
at_pointer += quant_.TotalBits();
bhiksha_.ReadNext(base_, at_pointer, index, total_bits_, range);
bhiksha_.ReadNext(base_, at_pointer, pointer, total_bits_, range);
return true;
}

View File

@ -99,10 +99,11 @@ template <class Quant, class Bhiksha> class BitPackedMiddle : public BitPacked {
bool FindNoProb(WordIndex word, float &backoff, NodeRange &range) const;
NodeRange ReadEntry(uint64_t pointer, float &prob) {
quant_.ReadProb(base_, pointer, prob);
uint64_t addr = pointer * total_bits_;
addr += word_bits_;
quant_.ReadProb(base_, addr, prob);
NodeRange ret;
// pointer/total_bits_ should always round down.
bhiksha_.ReadNext(base_, pointer + quant_.TotalBits(), pointer / total_bits_, total_bits_, ret);
bhiksha_.ReadNext(base_, addr + quant_.TotalBits(), pointer, total_bits_, ret);
return ret;
}