Init

API definition

APP_ERROR Init(int dim, int capacity, faiss::MetricType metricType, const std::vector<int> &deviceList, int64_t resourceSize = -1);

Function

Initialization function of AscendIndexILFlat.

Input

int dim: dimension of the feature vectors managed by AscendIndexILFlat.

int capacity: maximum database capacity. The API allocates capacity × dim × sizeof(fp16) bytes of memory data based on the value of capacity.

faiss::MetricType metricType: feature distance category (vector inner product, Euclidean distance, and cosine similarity).

const std::vector<int> &deviceList: resource configuration on the device.

int64_t resourceSize: preset memory pool size on the device, in bytes. It is the memory space for storing intermediate results during computing to prevent performance fluctuation caused by dynamic memory allocation. The default parameter is -1, indicating that the size is 128 MB.

Output

N/A

Return value

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

Restrictions

  • dim ∈ {32, 64, 128, 256, 384, 512}
  • metricType: Currently, AscendIndexILFlat supports only the vector inner product distance, that is only faiss::MetricType::METRIC_INNER_PRODUCT is supported.
  • capacity: The upper limit of the memory that can be allocated is 12,288,000,000 bytes, and the value range of capacity is [0, 12000000].
    • For 512-dimensional base vector of the FP16 type, the maximum supported capacity is 12 million (12288000000/(512 × sizeof(fp_16))).
    • For 256-dimensional base vector of the FP16 type, the maximum capacity can only be 12 million, though memory supports a larger capacity value.
  • Only single-device configuration is supported. deviceList.size() must be set to 1.
  • resourceSize: You can set this parameter to -1 or a value in the range of [134217728, 4294967296], which is equivalent to [128 MB, 4096 MB]. This parameter is determined by the database capacity and search batch size. If the database has 10 million vectors or more and the batch size is greater than or equal to 16, set this parameter to 1024 MB.