krl_IP_table_lookup_fast_scan_bs64
Interface Definition
int krl_IP_table_lookup_fast_scan_bs64(int nsq, const uint8_t* codes, const uint8_t* LUT, uint16_t* dis, uint16_t threshold, uint32_t* lt_mask, size_t codes_size, size_t LUT_size, size_t dis_size, size_t lt_mask_size);
Function
An operator designed for 4-bit table lookup, accumulation, filtering, and compression. It is used for processing float-type query vectors individually. It computes distances between a query vector and 64 base vectors using inner product. Based on the distance comparison rule, if a distance value meets the comparison rule, the bit in lt_mask of the corresponding base vector is set to 1. Otherwise, it is set to 0.
Parameters
Parameter |
Data Type |
Description |
Value Range |
|---|---|---|---|
nsq |
int |
Number of subspaces. |
An even number in [1, 256] |
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 uint8_t* |
Distance LUT, which stores the uint8 distances between product quantization (PQ) centroids and query vectors in each subspace. |
The size is specified by LUT_size. |
dis |
uint16_t* |
Stores the distance computation result. |
The size is specified by dis_size. The memory needs to be allocated in advance. |
threshold |
const uint16_t |
Distance threshold. |
The value is 65535. |
lt_mask |
uint32_t* |
Filtered and compressed results. |
The size is specified by lt_mask_size. The memory needs to be allocated in advance. |
codes_size |
size_t |
Length of the codebook array. |
nsq/2 x 64 |
LUT_size |
size_t |
Length of the distance LUT array. |
nsq x 16 |
dis_size |
size_t |
Size of the distance result array. |
The value is 64. |
lt_mask_size |
size_t |
Length of the array storing filtered and compressed results. |
The value is 2. |
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: |