Init

API definition

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());

Function

Initializes an instance.

Input

uint32_t deviceId: device ID used by the Index.

uint32_t dim: vector dimension.

uint32_t tokenNum: maximum number of tokens in the spatiotemporal database. The value must be the same as the number of tokens of the corresponding mask operator.

AlgorithmType algType: distance comparison algorithm used at the bottom layer. The default value is AlgorithmType::FLAT_COS_INT8. The options are as follows:

  • AlgorithmType::FLAT_HAMMING: binarized feature retrieval (Hamming distance)
  • AlgorithmType::FLAT_COS_INT8: Int8Flat (cosine distance)
  • AlgorithmType::FLAT_L2_INT8: Int8Flat (L2 distance)
  • AlgorithmType::FLAT_IP_FP16: FP16Flat (IP distance)
  • AlgorithmType::FLAT_HPP_COS_INT8: Int8Flat (cosine distance)
MemoryStrategy memoryStrategy: memory policy used at the bottom layer. The default value is MemoryStrategy::PURE_DEVICE_MEMORY. The options are as follows:
  • MemoryStrategy::PURE_DEVICE_MEMORY: pure-device memory policy
  • MemoryStrategy::HETERO_MEMORY: heterogeneous memory policy
  • MemoryStrategy::HPP: heterogeneous memory policy of the HPP

customAttrLen: length of a custom attribute

customAttrBlockSize: block size of a custom attribute

maxFeatureRowCount: maximum number of vectors

Output

N/A

Return value

APP_ERROR: return status. For details, see Return Code Reference.

Restrictions

  • It needs to be called immediately after the constructor.
  • deviceId must be a valid device ID. The value range is [0, 1024].
  • The value range of tokenNum is (0, 3e5].
  • For the binarized feature retrieval (Hamming distance) algorithm, dim ∈ {256, 512, 1024}.
  • For the Int8Flat (cosine distance and L2 distance) algorithm, dim ∈ {64, 128, 256, 384, 512, 768, 1024}. For the FP16Flat (IP distance) algorithm, dim ∈ {64, 128, 256, 384, 512, 768, 1024}.
  • Currently, memoryStrategy::HETERO_MEMORY supports only AlgorithmType::FLAT_COS_INT8.
  • The value range of customAttrLen is [0, 32]. The default value is 0, indicating that there is no custom attribute.
  • The value range of customAttrBlockSize is [0, 262144 × 64]. The value must be an integer multiple of 1024 × 256. The default value is 0, indicating that there is no custom attribute.
  • The value range of maxFeatureRowCount is [262144 × 64, 262144 × 550 × 3], which must be an integer multiple of 256. The default value is the maximum value of uint64. This parameter is valid only when MemoryStrategy memoryStrategy is set to MemoryStrategy::HPP.
  • When MemoryStrategy memoryStrategy is set to MemoryStrategy::HPP, the available memory on the host must be greater than or equal to 250 GB, and the number of idle physical CPU cores must be greater than or equal to 15. Currently, only 256-dimensional vectors can be searched.