示例#1
0
        public float readBackoff(NgramTrieBitarr bitArr, int memPtr, int bitOffset, int orderMinusTwo)
        {
            switch (quantType)
            {
            case QuantType.NO_QUANT:
                bitOffset += 31;
                return(bitArr.readFloat(memPtr, bitOffset));

            case QuantType.QUANT_16:
                int tableIdx = orderMinusTwo * 2 + 1;
                return(binsDecode(tableIdx, bitArr.readInt(memPtr, bitOffset, probMask)));

            //TODO implement different quantization stages
            default:
                throw new Error("Unsupported quantization type: " + quantType);
            }
        }
示例#2
0
        public float readProb(NgramTrieBitarr bitArr, int memPtr, int bitOffset, int orderMinusTwo)
        {
            switch (quantType)
            {
            case QuantType.NO_QUANT:
                return(bitArr.readNegativeFloat(memPtr, bitOffset));

            case QuantType.QUANT_16:
                int tableIdx = orderMinusTwo * 2;
                if (tableIdx < tables.Length - 1)
                {
                    bitOffset += backoffBits;
                }
                return(binsDecode(tableIdx, bitArr.readInt(memPtr, bitOffset, backoffMask)));

            //TODO implement different quantization stages
            default:
                throw new Error("Unsupported quantization type: " + quantType);
            }
        }