其他功能
IReduction
功能介绍
IReduction是特征检索组件中降维方法的统一接口,目前支持PCAR和NN两种降维算法。
CreateReduction接口
IReduction *CreateReduction(std::string typeName, const ReductionConfig &config); |
|
reduce接口
virtual void reduce(idx_t n, const float *x, float *res) const = 0; |
|
ReductionConfig接口
| 成员 | 类型 | 说明 |
|---|---|---|
| dimIn | int | 输入特征维度,即降维前的维度。PCAR需要配置此参数。 |
| dimOut | int | 输出特征维度,即降维后的维度。PCAR需要配置此参数。 |
| eigenPower | float | 奇异值的power数。PCAR需要配置此参数。 |
| randomRotation | bool | 是否进行随机旋转。PCAR需要配置此参数。 |
| deviceList | std::vector<int> | Device侧资源配置。NN需要配置此参数。 |
| model | const char * | 神经网络降维模型。NN需要配置此参数。 |
| modelSize | uint64_t | 模型的大小。NN需要配置此参数。 |
inline ReductionConfig(int dimIn, int dimOut, float eigenPower, bool randomRotation); |
|
int dimIn:输入特征维度,即降维前的维度,PCAR需要配置此参数。 int dimOut:输出特征维度,即降维后的维度,PCAR需要配置此参数。 |
|
~IReduction接口
train接口
AscendNNInference
功能介绍
通过神经网络执行推理。
AscendNNInference接口
AscendNNInference(std::vector<int> deviceList, const char* model, uint64_t modelSize); |
|
AscendNNInference的构造函数,生成AscendNNInference,此时根据“deviceList”中配置的值设置Device侧昇腾AI处理器资源以及模型路径等。 |
|
~AscendNNInference接口
getDimBatch接口
getInputType接口
getOutputType接口
getDimIn接口
getDimOut接口
infer接口
void infer(size_t n, const char* inputData, char* outputData) const; |
|
operator = 接口
AscendNNInference& operator=(const AscendNNInference&) = delete; |
|
AscendClonerOptions
功能介绍
AscendCloner接口的配置参数。
| 成员 | 类型 | 说明 |
|---|---|---|
| reserveVecs | long | 当前无效,预留内存的特征数。 |
| verbose | bool | 是否打印拷贝日志。 |
| resourceSize | int64_t | 资源池大小。 |
| slim | bool | AscendClonerOptions成员变量,是否动态增加内存。默认为false。 |
| filterable | bool | AscendClonerOptions成员变量,是否按照id进行过滤。默认为false。 |
| indexMode | uint32_t | Index int8检索模式,默认值为0 (DEFAULT_MODE)。 |
| blockSize | uint32_t | 配置Device侧的blockSize,默认值“BLOCK_SIZE”为16384 * 16 = 262144。 |
AscendClonerOptions接口
AscendCloner
功能介绍
Index SDK提供了将NPU上的检索Index资源拷贝到CPU侧Faiss的操作,拷贝过程发生在内存中,原始NPU的Index上加载的数据会被拷贝到CPU侧的内存中,方便用户在CPU上使用相同的底库执行检索。
Note
部分版本的Faiss中提供了将内存中的Index落盘(内存中的数据保存到本地硬盘)的方法,用户在基于Index SDK和Faiss处理某些敏感数据时需要特别注意提供对应的权限控制和加密保护。
index_ascend_to_cpu接口
faiss::Index *index_ascend_to_cpu(const faiss::Index *ascend_index); |
|
index_cpu_to_ascend接口
index_int8_ascend_to_cpu接口
faiss::Index *index_int8_ascend_to_cpu(const AscendIndexInt8 *index); |
|
index_int8_cpu_to_ascend接口
DiskPQ
功能介绍
Index SDK提供PQ(Product Quantization)量化的训练和检索功能。PQ接口不支持多线程并发调用,因此在多线程的场景中需要用户在使用前加锁,否则可能导致功能异常。
DiskPQParams接口
VectorArrayData接口
|
ComputePQTable接口
ComputeVectorPQCode接口
GetPQDistanceTable接口
GetPQDistance接口
GetVersionInfo
获取版本信息。会根据环境变量MX_INDEX_HOME来获取对应的版本信息,软件包安装时该环境变量会自动设置,无需修改。 |
|