Search
API definition |
APP_ERROR Search(int n, const float16_t *queries, int topk, idx_t *indices, float *distances, unsigned int tableLen = 0, const float *table = nullptr); |
|---|---|
Function |
Queries the top k indexes nearest to the query vector and the corresponding distances. For example, if a valid mapping table (tableLen > 0 and table is a non-null pointer) is transferred, the distance after mapping is output. |
Input |
int n: number of feature vectors to be queried. const float16_t *queries: feature vectors to be queried. The length is n × dim (vector dimension). int topk: sorts the distances between the query vector and the base vector and returns topk results. unsigned int tableLen: length of the mapping table. The default value is 0, indicating that no mapping is performed. Currently, the mapping table length can be set to 10000. const float *table: pointer to the mapping table, pointing to the storage space of valid mapping values with the tableLen length. Currently, the supported redundancy length is 48, that is, the length of the space to which table points is 10048 × sizeof(float) bytes. |
Output |
float *distances: external memory, indicating the cosine distance corresponding to topk × n feature vectors with the highest query similarity. The length is n × topk. idx_t *indices: external memory, indicating the indexes corresponding to the topk vectors with the highest query similarity. The length is n × topk. |
Return value |
APP_ERROR: return status. For details, see Return Code Reference. |
Restrictions |
|
API definition |
APP_ERROR Search(int n, const float *queries, int topk, idx_t *indices, float *distances, unsigned int tableLen = 0, const float *table = nullptr); |
|---|---|
Function |
Queries the top k indexes nearest to the query vector and the corresponding distances. For example, if a valid mapping table (tableLen > 0 and table is a non-null pointer) is transferred, the distance after mapping is output. |
Input |
int n: number of feature vectors to be queried. const float *queries: query vector. The length is n × dim (vector dimension). int topk: sorts the distances between the query vector and the base vector and returns topk results. unsigned int tableLen: length of the mapping table. The default value is 0, indicating that no mapping is performed. Currently, the mapping table length can be set to 10000. const float *table: pointer to the mapping table, pointing to the storage space of valid mapping values with the tableLen length. Currently, the supported redundancy length is 48, that is, the length of the space to which table points is 10048 × sizeof(float) bytes. |
Output |
float *distances: external memory, indicating the cosine distance corresponding to topk × n feature vectors with the highest query similarity. The length is n × topk. idx_t *indices: external memory, indicating the indexes corresponding to the topk vectors with the highest query similarity. The length is n × topk. |
Return value |
APP_ERROR: return status. For details, see Return Code Reference. |
Restrictions |
|