krl_table_lookup_4b_f16
Interface Definition
int krl_table_lookup_4b_f16(size_t nsq, size_t ncode, const uint8_t* codes, const uint16_t* LUT, float* dis, uint16_t dis0, size_t codes_size, size_t LUT_size, size_t dis_size);
Function
An operator designed for 4-bit table lookup, accumulation, filtering, and compression. It is used for processing fp16 query vectors individually. It computes distances between a query vector and multiple base vectors using inner product. The initial distance is dis0. This interface does not perform filtering or compression (that is, comparison with the threshold).
Parameters
Parameter |
Data Type |
Description |
Value Range |
|---|---|---|---|
nsq |
size_t |
Number of subspaces. |
An even number in [1, 65535] |
ncode |
size_t |
Total number of base vectors. |
[1, 2^30 – 1] |
codes |
const uint8_t* |
Codebook, which stores indexes of base vectors after krl_pack_codes_4b (blocksize=64) processing. |
The size is specified by codes_size. |
LUT |
const uint16_t* |
Distance LUT, which stores the fp16 distances between product quantization (PQ) centroids and query vectors in each subspace. |
The size is specified by LUT_size. |
dis |
float* |
Stores the distance computation results. |
The size is specified by dis_size. The memory needs to be allocated in advance. |
dis0 |
uint16_t |
Initial distance. |
Floating point number. |
codes_size |
size_t |
Length of the codebook array. |
nsq/2 x ncode |
LUT_size |
size_t |
Length of the distance LUT array. |
nsq x 16 |
dis_size |
size_t |
Specifies the size of the distance result array. |
The size is specified by ncode. |
Return Values
Data Type |
Description |
|---|---|
int |
0 is returned on successful execution. In case of failure, an error code is returned to indicate the specific issue:
|