结构体 faiss::gpu::GpuDistanceParams
-
struct GpuDistanceParams
用于暴力 GPU k 近邻搜索的参数。
公共成员
-
faiss::MetricType metric = METRIC_L2
搜索参数:距离度量。
-
float metricArg = 0
搜索参数:距离度量的参数(如果适用)。对于 metric == METRIC_Lp,这是 p 值
-
int k = 0
搜索参数:返回 k 个最近邻。如果提供的值为 -1,则我们报告所有成对距离,而不进行 top-k 过滤
-
int dims = 0
向量维度。
-
const void *vectors = nullptr
如果 vectorsRowMajor 为 true,则为 numVectors x dims,dims 在最内层;否则,为 dims x numVectors,numVectors 在最内层
-
DistanceDataType vectorType = DistanceDataType::F32
-
bool vectorsRowMajor = true
-
idx_t numVectors = 0
-
const float *vectorNorms = nullptr
预先计算好的
vectors
中每个向量的 L2 范数,可以选择提前提供,以加快 METRIC_L2 的计算速度
-
const void *queries = nullptr
如果 queriesRowMajor 为 true,则为 numQueries x dims,dims 在最内层;否则,为 dims x numQueries,numQueries 在最内层
-
DistanceDataType queryType = DistanceDataType::F32
-
bool queriesRowMajor = true
-
idx_t numQueries = 0
-
float *outDistances = nullptr
一个大小为 numQueries x k 的内存区域,如果 k > 0,则 k 在最内层(行主序),或者如果 k == -1,则为大小为 numQueries x numVectors 的内存区域
-
bool ignoreOutDistances = false
我们是否只关心报告的索引,而不是输出距离?如果 k == -1(所有成对距离),则不使用
-
IndicesDataType outIndicesType = IndicesDataType::I64
一个大小为 numQueries x k 的内存区域,k 在最内层(行主序)。如果 k == -1(所有成对距离),则不使用
-
void *outIndices = nullptr
-
int device = -1
搜索应在哪个 GPU 设备上运行?-1 表示使用当前 CUDA 线程本地设备(通过 cudaGetDevice/cudaSetDevice)。否则,整数 0 <= device < numDevices 表示执行的设备
-
bool use_cuvs = false
索引是否应向下分派到 cuVS?
-
faiss::MetricType metric = METRIC_L2