krl_table_lookup_8b_f32_by_idx
Interface Definition
int krl_table_lookup_8b_f32_by_idx(size_t nsq, size_t ncode, const uint8_t* codes, const float* sim_table, float* dis, float dis0, const size_t* idx, size_t codes_size, size_t sim_table_size, size_t dis_size);
Function
Obtains distance values from the float-type LUT using 8-bit indexes, accumulates the distance values, adds dis0 to the result after accumulation, and stores the final result in distance. Only the base vectors whose IDs are in the idx array are used for computation.
Parameters
Parameter |
Data Type |
Description |
Value Range |
|---|---|---|---|
nsq |
size_t |
Number of subspaces. |
[1, 65535] |
ncode |
size_t |
Number of vectors in the inverted list. |
[1, 2^30 – 1] |
codes |
const uint8_t* |
Codebook, which stores indexes of base vectors. |
The size is specified by codes_size. |
sim_table |
const float* |
Similarity LUT, which stores the distances between query vectors for each dimension and all centroids. |
The size is specified by sim_table_size. |
dis |
float* |
Stores the distance computation results. |
The size is specified by dis_size. The memory needs to be allocated in advance. |
dis0 |
float |
Initial distance. |
Floating point number. |
idx |
const size_t* |
Array of IDs of base vectors used for computation. |
The size is specified by ncode. The IDs need to be arranged in ascending order. |
codes_size |
size_t |
Length of the codebook array. |
nsq x ncode |
sim_table_size |
size_t |
Length of the similarity LUT array. |
nsq x 256 |
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:
|