文件 extra_distances-inl.h
定义
-
DISPATCH_VD(mt)
-
namespace faiss
使用多种变体的 k-means 聚类的实现。
版权所有 (c) Facebook, Inc. 及其附属公司。
此源代码已获得 MIT 许可的授权,该许可证位于此源代码树的根目录中的 LICENSE 文件中。
IDSelector 旨在定义要处理的向量子集(用于删除或作为搜索的子集)
PQ4 SIMD 打包和累积函数
基本内核将 nq 查询向量与 bbs = nb * 2 * 16 向量累积,并生成该向量的输出矩阵。 它对于 nq * nb <= 4 很有用,否则寄存器溢出将变得太大。
这些函数的实现分布在 3 个 cpp 文件中,以减少并行编译时间。 模板被显式实例化。
此文件包含计算距离的内核的回调。
在整个库中,向量以 float * 指针的形式提供。 当在批处理中一起处理(添加/搜索)多个向量时,可以优化大多数算法。 在这种情况下,它们作为矩阵传入。 当 n 个大小为 d 的向量以 float * x 的形式提供时,向量 i 的分量 j 为
x[ i * d + j ]
其中 0 <= i < n 且 0 <= j < d。换句话说,矩阵始终是紧凑的。 当指定矩阵的大小时,我们将其称为 n*d 矩阵,这意味着行优先存储。
I/O 函数可以读取/写入到文件名、文件句柄或抽象介质的对象。
读取函数返回的对象应使用 delete 释放。 这些对象中的所有引用都归对象所有。
反向列表的定义 + 一些实现该接口的常用类。
由于 IVF(倒排文件)索引对于大规模用例非常有用,我们将与它们相关的一些函数分组到这个小库中。 大多数函数都可以在 IndexIVF 和嵌入在 IndexPreTransform 中的 IndexIVF 上工作。
在此文件中实现了 L2 和内积之外的额外度量
实现一些神经网络层,主要为了支持 QINCo
定义一些将转换应用于向量集的对象。 这些通常是预处理步骤。
函数
-
template<class Consumer, class ...Types>
Consumer::T dispatch_VectorDistance(size_t d, MetricType metric, float metric_arg, Consumer &consumer, Types... args)
-
template<MetricType mt>
struct VectorDistance 公开类型
公开函数
-
inline float operator()(const float *x, const float *y) const
-
inline float operator()(const float *x, const float *y) const
-
inline float operator()(const float *x, const float *y) const
-
inline float operator()(const float *x, const float *y) const
-
inline float operator()(const float *x, const float *y) const
-
inline float operator()(const float *x, const float *y) const
-
inline float operator()(const float *x, const float *y) const
-
inline float operator()(const float *x, const float *y) const
-
inline float operator()(const float *x, const float *y) const
-
inline float operator()(const float *x, const float *y) const
-
inline float operator()(const float *x, const float *y) const
-
inline float operator()(const float *x, const float *y) const
公共静态属性
-
static constexpr bool is_similarity = is_similarity_metric(mt)
-
inline float operator()(const float *x, const float *y) const
-
template<class Consumer, class ...Types>