AscendIndexIVFSQ

当前“encodeResidual”“metric=faiss::MetricType::METRIC_INNER_PRODUCT”下,仅支持“false”取值,即当前并不支持对残差编码的IVFSQ方法,当取值为“true”时能够运行成功但存在精度问题。

API定义

AscendIndexIVFSQ(int dims, int nlist, faiss::ScalarQuantizer::QuantizerType qtype = ScalarQuantizer::QuantizerType::QT_8bit, faiss::MetricType metric = MetricType::METRIC_L2, bool encodeResidual = true, AscendIndexIVFSQConfig config = AscendIndexIVFSQConfig());

功能描述

AscendIndexIVFSQ的构造函数,生成AscendIndexIVFSQ,此时根据“config”中配置的值设置Device侧资源。

输入

int dims:AscendIndexIVFSQ管理的一组特征向量的维度。

int nlist:聚类中心的个数,与算子生成脚本中的“coarse_centroid_num”参数对应。

faiss::ScalarQuantizer::QuantizerType qtype:AscendIndexIVFSQ的量化器类型。

faiss::MetricType metric:AscendIndex在执行特征向量相似度检索的时候使用的距离度量类型。

bool encodeResidual:表示是否对残差编码。

AscendIndexIVFSQConfig config:Device侧资源配置。

输出

返回值

约束说明

  • dims ∈ {64, 128, 256, 384, 512}
  • nlist ∈ {1024, 2048, 4096, 8192, 16384, 32768}
  • qtype = ScalarQuantizer::QuantizerType::QT_8bit,当前仅支持“ScalarQuantizer::QuantizerType::QT_8bit”。
  • metric ∈ {faiss::MetricType::METRIC_L2,faiss::MetricType::METRIC_INNER_PRODUCT}