API定义
|
APP_ERROR Init(uint32_t deviceId, uint32_t dim, uint32_t tokenNum, AlgorithmType algType = AlgorithmType::FLAT_COS_INT8, MemoryStrategy memoryStrategy = MemoryStrategy::PURE_DEVICE_MEMORY, uint32_t customAttrLen = 0, uint32_t customAttrBlockSize = 0, uint64_t maxFeatureRowCount = std::numeric_limits<uint64_t>::max());
|
输入
|
uint32_t deviceId:Index使用的设备ID。
uint32_t dim:底库向量的维度。
uint32_t tokenNum:当前时空库Token的最大数量,需要和生成对应的Mask生成算子Token数量一致。
AlgorithmType algtype:底层使用的距离比对算法,默认为“AlgorithmType::FLAT_COS_INT8”,可选算法参见如下。
- “AlgorithmType::FLAT_HAMMING”:二值化特征检索(汉明距离)。
- “AlgorithmType::FLAT_COS_INT8”:Int8Flat(cos距离)。
- “AlgorithmType::FLAT_L2_INT8”:Int8Flat(L2距离)。
- “AlgorithmType::FLAT_IP_FP16”:Fp16Flat(IP距离)。
- “AlgorithmType::FLAT_HPP_COS_INT8”:Int8Flat(cos距离)。
MemoryStrategy memoryStrategy:底层使用的内存策略,默认为 “MemoryStrategy::PURE_DEVICE_MEMORY”,可选策略参见如下。 - MemoryStrategy::PURE_DEVICE_MEMORY:纯Device内存策略。
- MemoryStrategy::HETERO_MEMORY:异构内存策略。
- MemoryStrategy::HPP:HPP的异构内存策略。
customAttrLen:自定义属性长度。
customAttrBlockSize:自定义属性blocksize的大小。
maxFeatureRowCount:底库最大向量条数。
|
约束说明
|
- 需要紧跟在构造函数后调用。
- “deviceId”为有效的设备ID,设置范围为[0, 1024]。
- “tokenNum”设置范围为(0, 3e5]。
- 对于二值化特征检索(汉明距离)算法,dim ∈ {256, 512, 1024}。
- 对于Int8Flat(cos距离、L2距离)算法,dim ∈ {64, 128, 256, 384, 512, 768, 1024};对于Fp16Flat(IP距离)算法,dim ∈ {64, 128, 256, 384, 512, 1024}。
- “memoryStrategy::HETERO_MEMORY”当前只支持“AlgorithmType::FLAT_COS_INT8”算法。
- “customAttrLen”设置范围为[0, 32],默认值为“0”,设置为“0”时表示无自定义属性。
- “customAttrBlockSize”设置范围为[0, 262144*64],需要为1024*256的整数倍。默认值为“0”,设置为“0”时表示无自定义属性。
- “maxFeatureRowCount”设置范围为[262144 * 64, 262144 * 550 *3],需要为256的整数倍。默认值为uint64的最大值。该参数只在“MemoryStrategy memoryStrategy”设置为“MemoryStrategy::HPP”时有效。
- 当MemoryStrategy memoryStrategy设置为“MemoryStrategy::HPP”时,Host侧的可用内存需要大于等于250GB、空闲CPU物理核数需要大于等于15核,且目前仅支持256维向量的检索。
|