Init
API definition |
APP_ERROR Init(int dim, int capacity, AscendMetricType metricType, int64_t resourceSize = -1) override; |
|---|---|
Function |
Initializes feature database parameters and allocates 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 database capacity. The API allocates capacity × dim × sizeof(fp16) bytes of memory data based on the value of capacity. int64_t resourceSize: device cache resources allocated in advance. When the retrieval 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 retrieval service and the resource usage on the device. For example, if batch of a query operation is set to 64, the database has 1 million vectors, and an FP32 value occupies four bytes, resourceSize can be set to 256,000,000 bytes (64 × 1000000 × 4). Note that the maximum cache resources can be allocated internally by the API is 4 GB. |
Output |
N/A |
Return value |
APP_ERROR: return status. For details, see Return Code Reference. |
Restrictions |
|