Init
API Definition |
APP_ERROR Init(int dim, int capacity, AscendMetricType metricType, int resourceSize = -1) override |
|---|---|
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. The API allocates capacity x dim x sizeof(fp16) bytes of memory data based on the value of capacity. 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). Note that the maximum cache resources can be allocated internally by the API is 1 GB. |
Output |
N/A |
Return Value |
APP_ERROR: return status. For details, see Return Code Reference. |
Restrictions |
|