昇腾社区首页
中文
注册

AscendIndexIVFSQT接口

API定义

AscendIndexIVFSQT(const faiss::IndexIVFScalarQuantizer *index, AscendIndexIVFSQTConfig config = AscendIndexIVFSQTConfig());

功能描述

AscendIndexIVFSQT的构造函数,基于一个已有的“index”创建Ascend上的检索Index。

输入

const faiss::IndexIVFScalarQuantizer *index:CPU侧的Index资源。

AscendIndexIVFSQTConfig config:Device侧资源配置。

输出

返回值

约束说明

  • “index”需要为合法有效的CPU index指针。
  • index->d ∈ {256}。
  • index->sq.d ∈ {32, 64, 128}。
  • “index”的维度必须大于index->sq的维度且可以被index->sq的维度整除。

API定义

AscendIndexIVFSQT(int dimIn, int dimOut, int nlist, faiss::ScalarQuantizer::QuantizerType qtype = ScalarQuantizer::QuantizerType::QT_8bit, faiss::MetricType metric = MetricType::METRIC_INNER_PRODUCT, AscendIndexIVFSQTConfig config = AscendIndexIVFSQTConfig());

功能描述

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

输入

int dimIn:AscendIndexIVFSQT管理的一组原始特征向量的维度。

int dimOut:AscendIndexIVFSQT管理的一组降维目标特征向量的维度。

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

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

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

AscendIndexIVFSQTConfig config:Device侧资源配置。

输出

返回值

约束说明

  • dimIn ∈ {256}。
  • dimOut ∈ {32, 64, 128}。
  • nlist ∈ {1024, 2048, 4096, 8192, 16384, 32768}。
  • qtype = ScalarQuantizer::QuantizerType::QT_8bit,当前仅支持“ScalarQuantizer::QuantizerType::QT_8bit”量化器类型。
  • metric = faiss::MetricType::METRIC_INNER_PRODUCT (当前仅支持 “faiss::MetricType::METRIC_INNER_PRODUCT”。)

API定义

AscendIndexIVFSQT(const AscendIndexIVFSQT&) = delete;

功能描述

声明此index拷贝构造函数为空,即不可拷贝类型。

输入

const AscendIndexIVFSQT&:AscendIndexIVFSQT对象。

输出

返回值

约束说明