Init

API Definition

virtual APP_ERROR Init(int dim, int capacity, AscendMetricType metricType, int resourceSize) = 0

Function

Initializes feature library parameters and allocates base library memory resources.

Input

int dim: dimension of the feature vector.

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

int capacity: maximum capacity of the base library, which is equal to cap x dim x sizeof(float) bytes of memory data.

int resourceSize: allocates cache resources of the device in advance. When the search interface is called, the resources can be directly used without calling aclrtmalloc to allocate memory resources, achieving optimization acceleration. The default value is -1, indicating that cache resources (128 MB) are allocated based on the default size. You can configure the size based on the data volume of the search service and the resource usage on the device.

For example, if batch of a query operation is set to 64, the base library has 1 million vectors, and an FP32 value occupies four bytes, resourceSize is 256,000,000 bytes (64 x 1000000 x 4).

Output

N/A

Return Value

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

Restrictions

The input parameters must meet the requirements of the implementation class of this class.