|
XVector
|
Exact KNN (K-Nearest Neighbors) brute-force search interface. More...
#include "xvec_types.h"Go to the source code of this file.
Typedefs | |
| typedef struct xvecKnnExactSearchTiming | xvecKnnExactSearchTiming |
Functions | |
| xvecStatus | xvecKnnExactLoadIndexFromRawVectors (xvecExecutionContextTag *context, const xvecFloat32 *vectors, xvecVectorIdType vectorCount, xvecDimensionType dimension, xvecDistanceType distanceType, xvecKnnExactIndexTag **outIndexHandle) |
| Loads a KNN index from raw float32 vectors. More... | |
| xvecStatus | xvecKnnExactLoadIndexFromFaissFile (xvecExecutionContextTag *context, const char *indexFilePath, xvecKnnExactIndexTag **outIndexHandle) |
| Loads a KNN index from a Faiss IndexFlat file. More... | |
| xvecStatus | xvecKnnExactDestroyIndex (xvecExecutionContextTag *context, xvecKnnExactIndexTag *indexHandle) |
| Destroys a KNN index handle and releases its host-side data. More... | |
| xvecStatus | xvecKnnExactPrepareKernel (xvecExecutionContextTag *context) |
| Pre-initializes PXL resources (Job, Module, Function) for KNN search. More... | |
| xvecStatus | xvecKnnExactSearch (xvecExecutionContextTag *context, xvecKnnExactIndexTag *indexHandle, xvecKnnExactSearchQueryFloat32 *searchQuery, xvecBufferTag *resultsBufferHandle, xvecKnnExactSearchTiming *outTiming) |
| Performs a brute-force K-nearest neighbors search. More... | |
Exact KNN (K-Nearest Neighbors) brute-force search interface.
This header provides the API for loading and searching datasets using exact brute-force nearest neighbor search. KNN computes distances between every query vector and every target vector, providing exact results.
The parallel execution mode is automatically selected:
Definition in file xvec_knn_exact.h.
| typedef struct xvecKnnExactSearchTiming xvecKnnExactSearchTiming |
Definition at line 1 of file xvec_knn_exact.h.
| xvecStatus xvecKnnExactDestroyIndex | ( | xvecExecutionContextTag * | context, |
| xvecKnnExactIndexTag * | indexHandle | ||
| ) |
Destroys a KNN index handle and releases its host-side data.
| [in] | context | Execution context for device operations |
| [in] | indexHandle | Handle to the index to destroy |
| xvecStatus xvecKnnExactLoadIndexFromFaissFile | ( | xvecExecutionContextTag * | context, |
| const char * | indexFilePath, | ||
| xvecKnnExactIndexTag ** | outIndexHandle | ||
| ) |
Loads a KNN index from a Faiss IndexFlat file.
Loads an IndexFlat (or IndexFlatL2/IndexFlatIP) from a Faiss .faiss file, extracting vectors and distance metric.
| [in] | context | Execution context for device operations |
| [in] | indexFilePath | Path to the Faiss index file (.faiss) |
| [out] | outIndexHandle | Pointer to receive the handle to the loaded index. The caller is responsible for destroying this index using xvecKnnExactDestroyIndex. |
| xvecStatus xvecKnnExactLoadIndexFromRawVectors | ( | xvecExecutionContextTag * | context, |
| const xvecFloat32 * | vectors, | ||
| xvecVectorIdType | vectorCount, | ||
| xvecDimensionType | dimension, | ||
| xvecDistanceType | distanceType, | ||
| xvecKnnExactIndexTag ** | outIndexHandle | ||
| ) |
Loads a KNN index from raw float32 vectors.
This is the primary way to create a KNN index. The vectors are copied to device-accessible memory for accelerated search.
| [in] | context | Execution context for device operations |
| [in] | vectors | Pointer to row-major float32 vectors [vectorCount * dimension] |
| [in] | vectorCount | Number of vectors in the dataset |
| [in] | dimension | Dimension of each vector |
| [in] | distanceType | Distance metric (L2 or DOT_PRODUCT) |
| [out] | outIndexHandle | Pointer to receive the handle to the loaded index. The caller is responsible for destroying this index using xvecKnnExactDestroyIndex. |
| xvecStatus xvecKnnExactPrepareKernel | ( | xvecExecutionContextTag * | context | ) |
Pre-initializes PXL resources (Job, Module, Function) for KNN search.
Eagerly creates and caches the PXL Job and Function objects so that the first search call does not pay the lazy-initialization cost. Uses the same Sub count a search would: the "numSub" property if set, else whatever the device reports. Fails with XVEC_ERROR_DEVICE_NOT_SUPPORTED on a device that has no search path, rather than reserving Subs for a search that would then be refused. Fails with XVEC_ERROR_PXL_JOB_CREATE_FAILED when the device has fewer free Subs than the Job needs, because another process or context holds them.
| [in] | context | Execution context. Setting "numSub" is optional. |
| xvecStatus xvecKnnExactSearch | ( | xvecExecutionContextTag * | context, |
| xvecKnnExactIndexTag * | indexHandle, | ||
| xvecKnnExactSearchQueryFloat32 * | searchQuery, | ||
| xvecBufferTag * | resultsBufferHandle, | ||
| xvecKnnExactSearchTiming * | outTiming | ||
| ) |
Performs a brute-force K-nearest neighbors search.
Computes exact distances between every query vector and every target vector in the index, returning the top-K nearest neighbors for each query.
The parallel execution mode is automatically selected based on the number of queries and the device task count.
| [in] | context | Execution context for device operations |
| [in] | indexHandle | Handle to the KNN index containing target vectors |
| [in] | searchQuery | Search query parameters (queries, topK) |
| [out] | resultsBufferHandle | Buffer to receive search results. Must be pre-allocated with size: queryVectorCount * topK * sizeof(xvecKnnExactSearchResultFloat32) |
| [out] | outTiming | Pointer to receive timing information (can be NULL) |