deepmd.tf.nvnmd.utils.encode#
Attributes#
Classes#
Encoding value as hex, bin, and dec format. |
Module Contents#
- class deepmd.tf.nvnmd.utils.encode.Encode[source]#
Encoding value as hex, bin, and dec format.
- qr(v: numpy.ndarray | float, nbit: int = 14) numpy.ndarray | float[source]#
Quantize value using round.
- qf(v: numpy.ndarray | float, nbit: int = 14) numpy.ndarray | float[source]#
Quantize value using floor.
- qc(v: numpy.ndarray | float, nbit: int = 14) numpy.ndarray | float[source]#
Quantize value using ceil.
- split_expo_mant(v: numpy.ndarray | float, min: int = -1000) tuple[numpy.ndarray | float, numpy.ndarray | float][source]#
- norm_expo(v: numpy.ndarray | float, nbit_frac: int = 20, expo_min: int = -1000) tuple[numpy.ndarray | float, float][source]#
- flt2bin(data: numpy.ndarray, nbit_expo: int, nbit_frac: int) list[str][source]#
Convert float into binary string list.
- byte2hex(bs: bytes, nbyte: int) list[str][source]#
Convert byte into hex bs: low byte in the first hex: low byte in the right.
- check_dec(idec: numpy.ndarray, nbit: int, signed: bool = False, name: str = '') None[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: list[str], nfull: int) list[str][source]#
Extend the list (slbin) to the length (nfull) the attached element of list is 0.
such as, when
slbin = [‘10010’,’10100’],nfull = 4extent it to
[‘10010’,’10100’,’00000’,’00000]
- extend_bin(slbin: list[str], nfull: int) list[str][source]#
Extend the element of list (slbin) to the length (nfull).
such as, when
slbin = [‘10010’,’10100’],nfull = 6extent to
[‘010010’,’010100’]
- extend_hex(slhex: list[str], nfull: int) list[str][source]#
Extend the element of list (slhex) to the length (nfull).
- split_bin(sbin: str | list[str], nbit: int) list[str][source]#
Split sbin into many segment with the length nbit.
- reverse_bin(slbin: list[str], nreverse: int) list[str][source]#
Reverse binary string list per nreverse value.
- merge_bin(slbin: list[str], nmerge: int) list[str][source]#
Merge binary string list per nmerge value.
- dec2bin(idec: numpy.ndarray | float, nbit: int = 10, signed: bool = False, name: str = '') list[str][source]#
Convert dec array to binary string list.