将参数“config”传递给函数前,请根据实际情况先设置conf.handleBatch、conf.nprobe、conf.searchListSize的值(字段描述参考公共参数)。
其中conf.handleBatch、conf.searchListSize值需与IVFSP业务算子模型文件生成中的<nprobe handle batch>、<search list size>保持一致。
conf.filterable(继承自AscendIndexConfig)默认为“false”,如果要使用search_with_filter()接口,需设置conf.filterable = true。“conf.filterable”设置为“true”将在NPU卡上存储额外的信息,而消耗更多的NPU卡上内存。
API定义 |
AscendIndexIVFSP(int dims, int nonzeroNum, int nlist, const char *codeBookPath, faiss::ScalarQuantizer::QuantizerType qType = ScalarQuantizer::QuantizerType::QT_8bit, faiss::MetricType metric = MetricType::METRIC_L2, AscendIndexIVFSPConfig config = AscendIndexIVFSPConfig()); |
---|---|
功能描述 |
AscendIndexIVFSP的构造函数,根据“config”中配置的值设置Device侧资源。 |
输入 |
int dims:AscendIndexIVFSP管理的一组特征向量的维度。 int nonzeroNum:特征向量压缩降维后非零维度个数。 int nlist:聚类中心的个数,与IVFSP业务算子模型文件生成中的<centroid num>参数值对应。 const char *codeBookPath:IVFSP使用的码本文件路径。 faiss::ScalarQuantizer::QuantizerType qType:标量量化类型,当前仅支持“ScalarQuantizer::QuantizerType::QT_8bit”。 faiss::MetricType metric:AscendIndex在执行特征向量相似度检索的时候使用的距离度量类型。当前“faiss::MetricType metric”仅支持“METRIC_L2”。 AscendIndexIVFSPConfig:Device侧资源配置。 |
输出 |
无 |
返回值 |
无 |
约束说明 |
|