AscendIndexIVFSQ

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, inaccuracy occurs, though encodeResidual still runs.

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 is used to generate AscendIndexIVFSQ. The NPU 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 NPU.

Output

N/A

Return Value

N/A

Restrictions

  • dim ∈ {64, 128, 256, 384, 512, 1024, 2048}
  • 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}