AscendIndexFlatConfig

AscendIndexFlat requires the corresponding AscendIndexFlatConfig to initialize related resources.

API Description

API definition

inline AscendIndexFlatConfig()

Function

Default constructor of AscendIndexFlatConfig.

Input

N/A

Output

N/A

Return value

N/A

Restrictions

N/A

API definition

inline AscendIndexFlatConfig(std::initializer_list<int> devices, int64_t resourceSize = FLAT_DEFAULT_MEM)

Function

Constructor of AscendIndexFlatConfig, which is used to generate AscendIndexFlatConfig. The Ascend AI Processor resources on the device and the resource pool size are configured based on the value configured in devices.

Input

std::initializer_list<int> devices: device ID

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 FLAT_DEFAULT_MEM in the header file. This parameter is determined by the database capacity and search batch size. If the database has 4,194,304 records or more and the batch size is greater than or equal to 16, set this parameter as follows.

  • If the distance type of AscendIndexFlat is faiss::METRIC_L2, you are advised to set this parameter to 1024 MB.
  • If the distance type of AscendIndexFlat is faiss::METRIC_INNER_PRODUCT, you are advised to set this parameter to 1280 MB.

Output

N/A

Return value

N/A

Restrictions

  • The value of devices must be a valid and unique device ID. The maximum number of device IDs is 64.
  • The value of resourceSize cannot exceed 4 × 1024 MB (4 × 1024 × 1024 × 1024 bytes). When resourceSize is set to -1, the default value 128 MB is used for the Ascend AI Processor resource on the device.

API definition

inline AscendIndexFlatConfig(std::vector<int> devices, int64_t resourceSize = FLAT_DEFAULT_MEM)

Function

Constructor of AscendIndexFlatConfig, which is used to generate AscendIndexFlatConfig. The Ascend AI Processor resources on the device and the resource pool size are configured based on the value configured in devices.

Input

std::vector<int> devices: device ID

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 FLAT_DEFAULT_MEM in the header file. This parameter is determined by the database capacity and search batch size. If the database has 4,194,304 records or more and the batch size is greater than or equal to 16, set this parameter as follows.

  • If the distance type of AscendIndexFlat is faiss::METRIC_L2, you are advised to set this parameter to 1024 MB.
  • If the distance type of AscendIndexFlat is faiss::METRIC_INNER_PRODUCT, you are advised to set this parameter to 1280 MB.

Output

N/A

Return value

N/A

Restrictions

  • The value of devices must be a valid and unique device ID. The maximum number of device IDs is 64.
  • The value of resourceSize cannot exceed 4 × 1024 MB (4 × 1024 × 1024 × 1024 bytes). When resourceSize is set to -1, the default value 128 MB is used for the Ascend AI Processor resource on the device.