AscendIndexIVFSQ

API definition

AscendIndexIVFSQ(const faiss::IndexIVFScalarQuantizer *index, AscendIndexIVFSQConfig config = AscendIndexIVFSQConfig());

Function

Constructor of AscendIndexIVFSQ, which is used to create a retrieval index on the Ascend based on an existing index.

Input

const faiss::IndexIVFScalarQuantizer *index: resource configuration on the CPU.

AscendIndexIVFSQConfig config: resource configuration on the device.

Output

N/A

Return value

N/A

Restrictions

index must be a valid CPU Index pointer.

API definition

AscendIndexIVFSQ(int dims, int nlist, faiss::ScalarQuantizer::QuantizerType qtype = ScalarQuantizer::QuantizerType::QT_8bit, faiss::MetricType metric = MetricType::METRIC_L2, bool encodeResidual = true, AscendIndexIVFSQConfig config = AscendIndexIVFSQConfig());

Function

Constructor of AscendIndexIVFSQ, which generates AscendIndexIVFSQ. The device resources are set based on the value configured in config.

Input

int dims: dimensions of a group of feature vectors managed by AscendIndexIVFSQ.

int nlist: number of cluster centroids, which corresponds to coarse_centroid_num in the operator generation script.

faiss::ScalarQuantizer::QuantizerType qtype: quantizer type of AscendIndexIVFSQ.

faiss::MetricType metric: distance measurement type used by AscendIndex when it retrieves feature vector similarity.

bool encodeResidual: whether to encode residuals.

AscendIndexIVFSQConfig config: resource configuration on the device.

Output

N/A

Return value

N/A

Restrictions

  • dims ∈ {64, 128, 256, 384, 512}
  • nlist ∈ {1024, 2048, 4096, 8192, 16384, 32768}
  • qtype = ScalarQuantizer::QuantizerType::QT_8bit: Only ScalarQuantizer::QuantizerType::QT_8bit is supported.
  • metric ∈ {faiss::MetricType::METRIC_L2, faiss::MetricType::METRIC_INNER_PRODUCT}
    NOTE:

    Currently, encodeResidual in metric=faiss::MetricType::METRIC_INNER_PRODUCT supports only false. That is, encoding residuals using IVFSQ is not supported. If the value is set to true, precision loss occurs, though encodeResidual still runs.

API definition

AscendIndexIVFSQ(int dims, int nlist, faiss::MetricType metric, AscendIndexIVFSQConfig config);

Function

Constructor of AscendIndexIVFSQ, which generates AscendIndexIVFSQ. The device resources are set based on the value configured in config. This API does not perform initialization, which, instead, is performed by its subclass. This API will be deprecated later, and avoid using it.

Input

int dims: dimensions of a group of feature vectors managed by AscendIndexIVFSQ.

int nlist: number of cluster centroids, which corresponds to coarse_centroid_num in the operator generation script.

faiss::MetricType metric: distance measurement type used by AscendIndex when it retrieves feature vector similarity.

AscendIndexIVFSQConfig config: resource configuration on the device.

Output

N/A

Return value

N/A

Restrictions

  • dims ∈ {64, 128, 256, 384, 512}
  • nlist ∈ {1024, 2048, 4096, 8192, 16384, 32768}
  • metric ∈ {faiss::MetricType::METRIC_L2, faiss::MetricType::METRIC_INNER_PRODUCT}

API definition

AscendIndexIVFSQ(const AscendIndexIVFSQ&) = delete;

Function

Declares that the copy constructor of this Index class is void, that is, it cannot be copied.

Input

const AscendIndexIVFSQ&: constant AscendIndexIVFSQ

Output

N/A

Return value

N/A

Restrictions

N/A