|
XVector
|
IVF-Flat (Inverted File with Flat vectors) index interface. More...
#include "xvec_types.h"Go to the source code of this file.
Classes | |
| struct | xvecIvfFlatDescriptor |
| FAISS-free description of an IVF-Flat index. More... | |
Typedefs | |
| typedef struct xvecIvfFlatSearchTiming | xvecIvfFlatSearchTiming |
| typedef struct xvecIvfFlatDescriptor | xvecIvfFlatDescriptor |
| FAISS-free description of an IVF-Flat index. More... | |
Functions | |
| xvecStatus | xvecIvfFlatLoadIndexFromFaissFile (xvecExecutionContextTag *context, const char *indexFilePath, xvecIvfFlatIndexTag **outIndexHandle) |
| Loads an IVF-Flat index from a Faiss index file. More... | |
| xvecStatus | xvecIvfFlatLoadIndexFromDescriptor (xvecExecutionContextTag *context, const xvecIvfFlatDescriptor *descriptor, xvecIvfFlatIndexTag **outIndexHandle) |
| Loads an IVF-Flat index from a FAISS-free descriptor. More... | |
| xvecStatus | xvecIvfFlatDestroyIndex (xvecExecutionContextTag *context, xvecIvfFlatIndexTag *indexHandle) |
| Destroys an IVF-Flat index handle and releases its host-side data. More... | |
| xvecStatus | xvecIvfFlatPrepareKernel (xvecExecutionContextTag *context) |
| Pre-initializes PXL resources (Job, Module, Function) for IVF-Flat search. More... | |
| xvecStatus | xvecIvfFlatSearchFineSearchOnly (xvecExecutionContextTag *context, xvecIvfFlatIndexTag *indexHandle, xvecIvfFlatFineSearchQueryFloat32 *fineSearchQuery, xvecBufferTag *resultsBufferHandle, xvecIvfFlatSearchTiming *outTiming) |
| Performs an IVF-Flat fine search only (skips coarse search). More... | |
IVF-Flat (Inverted File with Flat vectors) index interface.
This header provides the API for loading, saving, and searching IVF-Flat indices. IVF-Flat uses inverted file indexing with exact distance computation within clusters, providing a good balance of speed and accuracy.
See Optional IVF-Flat L2 optimization for QUERY_FIXED L2 searches, configured through xvecSetContextProperty().
Definition in file xvec_ivf_flat.h.
| typedef struct xvecIvfFlatDescriptor xvecIvfFlatDescriptor |
FAISS-free description of an IVF-Flat index.
Fully describes an IVF-Flat index using plain C arrays, with no dependency on FAISS types or ABI. Vectors are grouped by cluster: the first listSizes[0] vectors belong to cluster 0, the next listSizes[1] to cluster 1, and so on.
All pointers are borrowed for the duration of the load call only; the caller retains ownership and may free them once the call returns.
| typedef struct xvecIvfFlatSearchTiming xvecIvfFlatSearchTiming |
Definition at line 1 of file xvec_ivf_flat.h.
| xvecStatus xvecIvfFlatDestroyIndex | ( | xvecExecutionContextTag * | context, |
| xvecIvfFlatIndexTag * | indexHandle | ||
| ) |
Destroys an IVF-Flat index handle and releases its host-side data.
| [in] | context | Execution context for device operations |
| [in] | indexHandle | Handle to the index to destroy |
| xvecStatus xvecIvfFlatLoadIndexFromDescriptor | ( | xvecExecutionContextTag * | context, |
| const xvecIvfFlatDescriptor * | descriptor, | ||
| xvecIvfFlatIndexTag ** | outIndexHandle | ||
| ) |
Loads an IVF-Flat index from a FAISS-free descriptor.
Builds an IVF-Flat index directly from caller-supplied arrays, with no FAISS dependency. This is the recommended way to construct an index from a custom or pre-extracted source. See xvecIvfFlatDescriptor for the required memory layout.
| [in] | context | Execution context for device operations |
| [in] | descriptor | Fully-populated index descriptor (borrowed for the call) |
| [out] | outIndexHandle | Pointer to receive the handle to the loaded index. The caller is responsible for destroying this index using xvecIvfFlatDestroyIndex. |
| xvecStatus xvecIvfFlatLoadIndexFromFaissFile | ( | xvecExecutionContextTag * | context, |
| const char * | indexFilePath, | ||
| xvecIvfFlatIndexTag ** | outIndexHandle | ||
| ) |
Loads an IVF-Flat index from a Faiss index file.
Loads an IndexIVFFlat from a Faiss .faiss file, extracting vectors, cluster centroids, and inverted list structure.
| [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 xvecIvfFlatDestroyIndex. |
| xvecStatus xvecIvfFlatPrepareKernel | ( | xvecExecutionContextTag * | context | ) |
Pre-initializes PXL resources (Job, Module, Function) for IVF-Flat 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. Safe to call more than once; subsequent calls are no-ops if numSub has not changed.
| [in] | context | Execution context. Setting "numSub" is optional. |
| xvecStatus xvecIvfFlatSearchFineSearchOnly | ( | xvecExecutionContextTag * | context, |
| xvecIvfFlatIndexTag * | indexHandle, | ||
| xvecIvfFlatFineSearchQueryFloat32 * | fineSearchQuery, | ||
| xvecBufferTag * | resultsBufferHandle, | ||
| xvecIvfFlatSearchTiming * | outTiming | ||
| ) |
Performs an IVF-Flat fine search only (skips coarse search).
This function performs only the fine search phase using pre-computed nearest cluster IDs. Use this when the coarse search has already been performed externally (e.g., by FAISS) and only the fine search needs to be offloaded to XVector.
The typical use case is XFaiss integration where:
| [in] | context | Execution context for device operations |
| [in] | indexHandle | Handle to the IVF-Flat index containing inverted lists |
| [in] | fineSearchQuery | Fine search query containing query vectors and pre-computed nearest cluster IDs (from external coarse search) |
| [out] | resultsBufferHandle | Buffer to receive search results. Must be pre-allocated with size: queryVectorCount * topK * sizeof(xvecIvfFlatSearchResultFloat32) |
| [out] | outTiming | Pointer to receive timing information (can be NULL) |