Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions faiss/AutoTune.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

#include <cinttypes>
#include <cmath>
#include <typeinfo>

#include <faiss/impl/FaissAssert.h>
#include <faiss/utils/random.h>
Expand Down Expand Up @@ -313,9 +312,6 @@ bool ParameterSpace::combination_ge(size_t c1, size_t c2) const {
return true;
}

#define DC(classname) \
[[maybe_unused]] const classname* ix = dynamic_cast<const classname*>(index)

static void init_pq_ParameterRange(
const ProductQuantizer& pq,
ParameterRange& pr) {
Expand All @@ -339,6 +335,10 @@ ParameterRange& ParameterSpace::add_range(const std::string& name) {
return parameter_ranges.back();
}

// Do not use this macro if ix will be unused
#define DC(classname) \
const classname* ix = dynamic_cast<const classname*>(index)

/// initialize with reasonable parameters for this type of index
void ParameterSpace::initialize(const Index* index) {
if (DC(IndexPreTransform)) {
Expand Down Expand Up @@ -394,7 +394,7 @@ void ParameterSpace::initialize(const Index* index) {
std::numeric_limits<double>::infinity());
}
}
if (DC(IndexIVFPQR)) {
if (dynamic_cast<const IndexIVFPQR*>(index)) {
ParameterRange& pr = add_range("k_factor");
for (int i = 0; i <= 6; i++) {
pr.values.push_back(1 << i);
Expand All @@ -410,9 +410,6 @@ void ParameterSpace::initialize(const Index* index) {

#undef DC

// non-const version
#define DC(classname) classname* ix = dynamic_cast<classname*>(index)

/// set a combination of parameters on an index
void ParameterSpace::set_index_parameters(Index* index, size_t cno) const {
for (int i = 0; i < parameter_ranges.size(); i++) {
Expand Down Expand Up @@ -442,6 +439,10 @@ void ParameterSpace::set_index_parameters(
}
}

// non-const version
// Do not use this macro if ix will be unused
#define DC(classname) classname* ix = dynamic_cast<classname*>(index)

void ParameterSpace::set_index_parameter(
Index* index,
const std::string& name,
Expand Down Expand Up @@ -574,6 +575,8 @@ void ParameterSpace::set_index_parameter(
name.c_str());
}

#undef DC

void ParameterSpace::display() const {
printf("ParameterSpace, %zd parameters, %zd combinations:\n",
parameter_ranges.size(),
Expand Down
4 changes: 1 addition & 3 deletions faiss/IndexHNSW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
#include <faiss/IndexHNSW.h>

#include <omp.h>
#include <cassert>
#include <cinttypes>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
Expand Down Expand Up @@ -124,7 +122,7 @@ void hnsw_add_vertices(
int i1 = n;

for (int pt_level = hist.size() - 1;
pt_level >= !index_hnsw.init_level0;
pt_level >= int(!index_hnsw.init_level0);
pt_level--) {
int i0 = i1 - hist[pt_level];

Expand Down
1 change: 0 additions & 1 deletion faiss/impl/HNSW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <faiss/impl/HNSW.h>

#include <cstddef>
#include <string>

#include <faiss/impl/AuxIndexStructures.h>
#include <faiss/impl/DistanceComputer.h>
Expand Down
7 changes: 2 additions & 5 deletions faiss/index_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@

#include <faiss/index_factory.h>

#include <cinttypes>
#include <cmath>

#include <map>

#include <regex>
Expand Down Expand Up @@ -164,7 +161,7 @@ const std::string aq_norm_pattern =
const std::string paq_def_pattern = "([0-9]+)x([0-9]+)x([0-9]+)";

AdditiveQuantizer::Search_type_t aq_parse_search_type(
std::string stok,
const std::string& stok,
MetricType metric) {
if (stok == "") {
return metric == METRIC_L2 ? AdditiveQuantizer::ST_decompress
Expand Down Expand Up @@ -766,7 +763,7 @@ std::unique_ptr<Index> index_factory_sub(
}

if (verbose) {
printf("after () normalization: %s %ld parenthesis indexes d=%d\n",
printf("after () normalization: %s %zd parenthesis indexes d=%d\n",
description.c_str(),
parenthesis_indexes.size(),
d);
Expand Down
Loading