1720 - expose FAISS version field to c_api (#3635)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3635 Add a util function to return the version in the c api. Reviewed By: ramilbakhshyiev, fxdawnn Differential Revision: D59817407 fbshipit-source-id: ca805f8e04f554d0294ba9da8ec6dc7c31e91fe3pull/3534/head^2
parent
749163e1d0
commit
8b5895ff79
|
@ -20,6 +20,18 @@
|
|||
#define FAISS_VERSION_MINOR 8
|
||||
#define FAISS_VERSION_PATCH 0
|
||||
|
||||
// Macro to combine the version components into a single string
|
||||
#ifndef FAISS_STRINGIFY
|
||||
#define FAISS_STRINGIFY(ARG) #ARG
|
||||
#endif
|
||||
#ifndef FAISS_TOSTRING
|
||||
#define FAISS_TOSTRING(ARG) FAISS_STRINGIFY(ARG)
|
||||
#endif
|
||||
#define VERSION_STRING \
|
||||
FAISS_TOSTRING(FAISS_VERSION_MAJOR) \
|
||||
"." FAISS_TOSTRING(FAISS_VERSION_MINOR) "." FAISS_TOSTRING( \
|
||||
FAISS_VERSION_PATCH)
|
||||
|
||||
/**
|
||||
* @namespace faiss
|
||||
*
|
||||
|
@ -38,8 +50,8 @@
|
|||
|
||||
namespace faiss {
|
||||
|
||||
/// Forward declarations see impl/AuxIndexStructures.h, impl/IDSelector.h and
|
||||
/// impl/DistanceComputer.h
|
||||
/// Forward declarations see impl/AuxIndexStructures.h, impl/IDSelector.h
|
||||
/// and impl/DistanceComputer.h
|
||||
struct IDSelector;
|
||||
struct RangeSearchResult;
|
||||
struct DistanceComputer;
|
||||
|
@ -56,7 +68,8 @@ struct SearchParameters {
|
|||
virtual ~SearchParameters() {}
|
||||
};
|
||||
|
||||
/** Abstract structure for an index, supports adding vectors and searching them.
|
||||
/** Abstract structure for an index, supports adding vectors and searching
|
||||
* them.
|
||||
*
|
||||
* All vectors provided at add or search time are 32-bit float arrays,
|
||||
* although the internal representation may vary.
|
||||
|
@ -154,7 +167,8 @@ struct Index {
|
|||
|
||||
/** return the indexes of the k vectors closest to the query x.
|
||||
*
|
||||
* This function is identical as search but only return labels of neighbors.
|
||||
* This function is identical as search but only return labels of
|
||||
* neighbors.
|
||||
* @param n number of vectors
|
||||
* @param x input vectors to search, size n * d
|
||||
* @param labels output labels of the NNs, size n*k
|
||||
|
@ -179,7 +193,8 @@ struct Index {
|
|||
*/
|
||||
virtual void reconstruct(idx_t key, float* recons) const;
|
||||
|
||||
/** Reconstruct several stored vectors (or an approximation if lossy coding)
|
||||
/** Reconstruct several stored vectors (or an approximation if lossy
|
||||
* coding)
|
||||
*
|
||||
* this function may not be defined for some indexes
|
||||
* @param n number of vectors to reconstruct
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
// -*- c++ -*-
|
||||
|
||||
#include <faiss/Index.h>
|
||||
#include <faiss/utils/utils.h>
|
||||
|
||||
#include <cassert>
|
||||
|
@ -129,6 +130,10 @@ std::string get_compile_options() {
|
|||
return options;
|
||||
}
|
||||
|
||||
std::string get_version() {
|
||||
return VERSION_STRING;
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
double getmillisecs() {
|
||||
LARGE_INTEGER ts;
|
||||
|
|
|
@ -37,6 +37,9 @@ std::string get_compile_options();
|
|||
* Get some stats about the system
|
||||
**************************************************/
|
||||
|
||||
// Expose FAISS version as a string
|
||||
std::string get_version();
|
||||
|
||||
/// ms elapsed since some arbitrary epoch
|
||||
double getmillisecs();
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ set(FAISS_TEST_SRC
|
|||
test_disable_pq_sdc_tables.cpp
|
||||
test_common_ivf_empty_index.cpp
|
||||
test_callback.cpp
|
||||
test_utils.cpp
|
||||
)
|
||||
|
||||
add_executable(faiss_test ${FAISS_TEST_SRC})
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <faiss/Index.h>
|
||||
#include <faiss/utils/utils.h>
|
||||
|
||||
TEST(TestUtils, get_version) {
|
||||
std::string version = std::to_string(FAISS_VERSION_MAJOR) + "." +
|
||||
std::to_string(FAISS_VERSION_MINOR) + "." +
|
||||
std::to_string(FAISS_VERSION_PATCH);
|
||||
|
||||
EXPECT_EQ(version, faiss::get_version());
|
||||
}
|
Loading…
Reference in New Issue