krl_pack_codes_4b
Interface Definition
int krl_pack_codes_4b(const uint8_t* codes, size_t ncode, size_t nsq, uint8_t* blocks, size_t batchsize, int dim_cross, size_t codes_size, size_t blocks_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 dis_f16. This interface does not perform filtering or compression (that is, comparison with the threshold).
Parameters
Parameter |
Data Type |
Description |
Value Range |
|---|---|---|---|
codes |
const uint8_t* |
Base vector data. |
The size is specified by codes_size. |
ncode |
size_t |
Total number of base vectors. |
[1, 2^30 – 1] |
nsq |
size_t |
Number of subspaces. |
[1, 65535] |
blocks |
uint8_t* |
Packed base vector data. |
The size is specified by blocks_size. The memory needs to be allocated in advance. |
batchsize |
size_t |
Base vector block size. |
The value is greater than 0 and is a multiple of 16. The value must match table lookup accumulation operators.
krl_table_lookup_step
krl_L2_table_lookup_fast_scan_bs64 krl_IP_table_lookup_fast_scan_bs64 krl_table_lookup_4b_f16
krl_L2_table_lookup_fast_scan_bs96 krl_IP_table_lookup_fast_scan_bs96 |
dim_cross |
int |
Indicates whether the distance data is 8-bit. |
[0, 1]
|
codes_size |
size_t |
Size of the base vector array. |
ncode x nsq/2 |
blocks_size |
size_t |
Size of the packed base vector array. |
ceil(ncode/batchsize) x batchsize x ceil(nsq/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:
|