InitWithQuantify

API definition

APP_ERROR InitWithQuantify(uint32_t deviceId, uint32_t dim, uint32_t tokenNum, uint64_t resources, const float *scale, AlgorithmType algType = AlgorithmType::FLAT_IP_FP16, uint32_t customAttrLen = 0, uint32_t customAttrBlockSize = 0);

Function

Initializes vectors with quantization.

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.

uint64_t resources: size of the shared memory.

const float *scale: scaling factor for vectorization. The scaling factor needs to be multiplied by the vector and then converted into the int8_t type.

AlgorithmType algType: distance comparison algorithm used at the bottom layer. The default value is AlgorithmType:: FLAT_IP_FP16, indicating FP16Flat (IP distance). Currently, this algorithm is only supported.

uint32_t customAttrLen: length of a custom attribute

uint32_t customAttrBlockSize: block size of a custom attribute

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].
  • The value range of uint64_t resources is (0, 4 × 1024 × 1024 × 1024].
  • The scale factor must not approach 0 because division is required during scale dequantization, and its absolute value must be greater than or equal to 1e-6f.
  • For the FP16Flat (IP distance) algorithm, dim ∈ {64, 128, 256, 384, 512, 768, 1024}.
  • Currently, only the non-sharing mode of the FP16Flat (IP distance) algorithm is supported.
  • This API is used together with AddFeatureByIndice.
  • 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.