Init
API definition |
virtual APP_ERROR Init(int dim, int capacity, AscendMetricType metricType, int64_t resourceSize) = 0; |
|---|---|
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, which is equal to capacity × dim × sizeof(float) bytes of memory data. int 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 then can be set to 256,000,000 bytes (64 × 1000000 × 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. |