Skip to content

Commit 3d3a45f

Browse files
bshethmetafacebook-github-bot
authored andcommitted
1720 - expose FAISS version field to c_api (#3635)
Summary: Pull Request resolved: #3635 Add a util function to return the version in the c api. Differential Revision: D59817407
1 parent dd72e41 commit 3d3a45f

3 files changed

Lines changed: 26 additions & 0 deletions

File tree

faiss/utils/utils.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
// -*- c++ -*-
99

10+
#include <faiss/Index.h>
1011
#include <faiss/utils/utils.h>
1112

1213
#include <cassert>
@@ -129,6 +130,14 @@ std::string get_compile_options() {
129130
return options;
130131
}
131132

133+
std::string get_version() {
134+
std::string version = std::to_string(FAISS_VERSION_MAJOR) + "." +
135+
std::to_string(FAISS_VERSION_MINOR) + "." +
136+
std::to_string(FAISS_VERSION_PATCH);
137+
138+
return version;
139+
}
140+
132141
#ifdef _MSC_VER
133142
double getmillisecs() {
134143
LARGE_INTEGER ts;

faiss/utils/utils.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ std::string get_compile_options();
3737
* Get some stats about the system
3838
**************************************************/
3939

40+
// Expose FAISS version as a string
41+
std::string get_version();
42+
4043
/// ms elapsed since some arbitrary epoch
4144
double getmillisecs();
4245

tests/test_utils.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
#include <gtest/gtest.h>
9+
10+
#include <faiss/utils/utils.h>
11+
12+
TEST(TestUtils, get_version) {
13+
EXPECT_EQ("1.8.0", faiss::get_version());
14+
}

0 commit comments

Comments
 (0)