deepmd.tf.nvnmd.utils.encode

Module Contents

Classes

Encode

Encoding value as hex, bin, and dec format.

Attributes

log

deepmd.tf.nvnmd.utils.encode.log[source]
class deepmd.tf.nvnmd.utils.encode.Encode[source]

Encoding value as hex, bin, and dec format.

qr(v, nbit: int = 14)[source]

Quantize value using round.

qf(v, nbit: int = 14)[source]

Quantize value using floor.

qc(v, nbit: int = 14)[source]

Quantize value using ceil.

split_expo_mant(v, min=-1000)[source]
find_max_expo(v, expo_min=-1000)[source]
norm_expo(v, nbit_frac=20, expo_min=-1000)[source]
flt2bin_one(v, nbit_expo, nbit_frac)[source]
flt2bin(data, nbit_expo, nbit_frac)[source]

Convert float into binary string list.

byte2hex(bs, nbyte)[source]

Convert byte into hex bs: low byte in the first hex: low byte in the right.

check_dec(idec, nbit, signed=False, name='')[source]

Check whether the data (idec) is in the range range is \([0, 2^nbit-1]\) for unsigned range is \([-2^{nbit-1}, 2^{nbit-1}-1]\) for signed.

extend_list(slbin, nfull)[source]

Extend the list (slbin) to the length (nfull) the attched element of list is 0.

such as, when

slbin = [‘10010’,’10100’],
nfull = 4

extent it to

[‘10010’,’10100’,’00000’,’00000]

extend_bin(slbin, nfull)[source]

Extend the element of list (slbin) to the length (nfull).

such as, when

slbin = [‘10010’,’10100’],
nfull = 6

extent to

[‘010010’,’010100’]

extend_hex(slhex, nfull)[source]

Extend the element of list (slhex) to the length (nfull).

split_bin(sbin, nbit: int)[source]

Split sbin into many segment with the length nbit.

reverse_bin(slbin, nreverse)[source]

Reverse binary string list per nreverse value.

merge_bin(slbin, nmerge)[source]

Merge binary string list per nmerge value.

dec2bin(idec, nbit=10, signed=False, name='')[source]

Convert dec array to binary string list.

hex2bin_str(shex)[source]

Convert hex string to binary string.

hex2bin(data)[source]

Convert hex string list to binary string list.

bin2hex_str(sbin)[source]

Convert binary string to hex string.

bin2hex(data)[source]

Convert binary string list to hex string list.