mirror of
https://github.com/facebookresearch/faiss.git
synced 2026-10-12 02:13:36 +00:00
Export static/extern globals. (#1373)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/1373 Test Plan: Imported from OSS Reviewed By: mdouze Differential Revision: D23314736 Pulled By: beauby fbshipit-source-id: 321d1fe510d9cb9fbb08b7b089a0ea420e215fa8
This commit is contained in:
committed by
Facebook GitHub Bot
parent
6d3c49bad6
commit
e520756b1c
@@ -107,6 +107,7 @@ set(FAISS_HEADERS
|
||||
impl/io.h
|
||||
impl/io_macros.h
|
||||
impl/lattice_Zn.h
|
||||
impl/platform_macros.h
|
||||
utils/Heap.h
|
||||
utils/WorkerThread.h
|
||||
utils/distances.h
|
||||
@@ -134,6 +135,10 @@ set_target_properties(faiss PROPERTIES
|
||||
WINDOWS_EXPORT_ALL_SYMBOLS ON
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
target_compile_definitions(faiss PRIVATE FAISS_MAIN_LIB)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(faiss PRIVATE FINTEGER=int)
|
||||
|
||||
find_package(OpenMP REQUIRED)
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include <faiss/IndexBinary.h>
|
||||
#include <faiss/IndexBinaryFlat.h>
|
||||
#include <faiss/impl/platform_macros.h>
|
||||
#include <faiss/utils/Heap.h>
|
||||
|
||||
|
||||
@@ -71,7 +72,7 @@ struct IndexBinaryHashStats {
|
||||
void reset ();
|
||||
};
|
||||
|
||||
extern IndexBinaryHashStats indexBinaryHash_stats;
|
||||
FAISS_API extern IndexBinaryHashStats indexBinaryHash_stats;
|
||||
|
||||
|
||||
/** just uses the b first bits as a hash value */
|
||||
|
||||
+2
-1
@@ -19,6 +19,7 @@
|
||||
#include <faiss/InvertedLists.h>
|
||||
#include <faiss/DirectMap.h>
|
||||
#include <faiss/Clustering.h>
|
||||
#include <faiss/impl/platform_macros.h>
|
||||
#include <faiss/utils/Heap.h>
|
||||
|
||||
|
||||
@@ -364,7 +365,7 @@ struct IndexIVFStats {
|
||||
};
|
||||
|
||||
// global var that collects them all
|
||||
extern IndexIVFStats indexIVF_stats;
|
||||
FAISS_API extern IndexIVFStats indexIVF_stats;
|
||||
|
||||
|
||||
} // namespace faiss
|
||||
|
||||
+3
-2
@@ -15,6 +15,7 @@
|
||||
|
||||
#include <faiss/IndexIVF.h>
|
||||
#include <faiss/IndexPQ.h>
|
||||
#include <faiss/impl/platform_macros.h>
|
||||
|
||||
|
||||
namespace faiss {
|
||||
@@ -30,7 +31,7 @@ struct IVFPQSearchParameters: IVFSearchParameters {
|
||||
/** Inverted file with Product Quantizer encoding. Each residual
|
||||
* vector is encoded as a product quantizer code.
|
||||
*/
|
||||
struct IndexIVFPQ: IndexIVF {
|
||||
struct FAISS_API IndexIVFPQ: IndexIVF {
|
||||
bool by_residual; ///< Encode residual or plain vector?
|
||||
|
||||
ProductQuantizer pq; ///< produces the codes
|
||||
@@ -150,7 +151,7 @@ struct IndexIVFPQStats {
|
||||
};
|
||||
|
||||
// global var that collects them all
|
||||
extern IndexIVFPQStats indexIVFPQ_stats;
|
||||
FAISS_API extern IndexIVFPQStats indexIVFPQ_stats;
|
||||
|
||||
|
||||
|
||||
|
||||
+3
-1
@@ -17,6 +17,8 @@
|
||||
#include <faiss/Index.h>
|
||||
#include <faiss/impl/ProductQuantizer.h>
|
||||
#include <faiss/impl/PolysemousTraining.h>
|
||||
#include <faiss/impl/platform_macros.h>
|
||||
|
||||
|
||||
namespace faiss {
|
||||
|
||||
@@ -138,7 +140,7 @@ struct IndexPQStats {
|
||||
void reset ();
|
||||
};
|
||||
|
||||
extern IndexPQStats indexPQ_stats;
|
||||
FAISS_API extern IndexPQStats indexPQ_stats;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#include <mutex>
|
||||
|
||||
#include <faiss/Index.h>
|
||||
#include <faiss/impl/platform_macros.h>
|
||||
|
||||
|
||||
namespace faiss {
|
||||
|
||||
@@ -218,7 +220,7 @@ struct DistanceComputer {
|
||||
* Interrupt callback
|
||||
***********************************************************/
|
||||
|
||||
struct InterruptCallback {
|
||||
struct FAISS_API InterruptCallback {
|
||||
virtual bool want_interrupt () = 0;
|
||||
virtual ~InterruptCallback() {}
|
||||
|
||||
|
||||
+2
-1
@@ -19,6 +19,7 @@
|
||||
#include <faiss/impl/FaissAssert.h>
|
||||
#include <faiss/utils/random.h>
|
||||
#include <faiss/utils/Heap.h>
|
||||
#include <faiss/impl/platform_macros.h>
|
||||
|
||||
|
||||
namespace faiss {
|
||||
@@ -276,7 +277,7 @@ struct HNSWStats {
|
||||
};
|
||||
|
||||
// global var that collects them all
|
||||
extern HNSWStats hnsw_stats;
|
||||
FAISS_API extern HNSWStats hnsw_stats;
|
||||
|
||||
|
||||
} // namespace faiss
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#ifdef FAISS_MAIN_LIB
|
||||
#define FAISS_API __declspec(dllexport)
|
||||
#else // _FAISS_MAIN_LIB
|
||||
#define FAISS_API __declspec(dllimport)
|
||||
#endif // FAISS_MAIN_LIB
|
||||
#else
|
||||
#define FAISS_API
|
||||
#endif // _MSC_VER
|
||||
@@ -16,6 +16,14 @@
|
||||
|
||||
%module swigfaiss;
|
||||
|
||||
// NOTE: While parsing the headers to generate the interface, SWIG does not know
|
||||
// about `_MSC_VER`.
|
||||
// TODO: Remove the need for this hack.
|
||||
#ifdef SWIGWIN
|
||||
#define _MSC_VER
|
||||
%include <windows.i>
|
||||
#endif // SWIGWIN
|
||||
|
||||
// fbode SWIG fails on warnings, so make them non fatal
|
||||
#pragma SWIG nowarn=321
|
||||
#pragma SWIG nowarn=403
|
||||
@@ -230,6 +238,7 @@ namespace std {
|
||||
* Parse headers
|
||||
*******************************************************************/
|
||||
|
||||
%include <faiss/impl/platform_macros.h>
|
||||
|
||||
%ignore *::cmp;
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <faiss/utils/Heap.h>
|
||||
#include <faiss/impl/platform_macros.h>
|
||||
|
||||
|
||||
namespace faiss {
|
||||
@@ -153,7 +154,7 @@ void pairwise_indexed_inner_product (
|
||||
***************************************************************************/
|
||||
|
||||
// threshold on nx above which we switch to BLAS to compute distances
|
||||
extern int distance_compute_blas_threshold;
|
||||
FAISS_API extern int distance_compute_blas_threshold;
|
||||
|
||||
/** Return the k nearest neighors of each of the nx vectors x among the ny
|
||||
* vector y, w.r.t to max inner product
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#define __builtin_popcountl __popcnt64
|
||||
#endif // _MSC_VER
|
||||
|
||||
#include <faiss/impl/platform_macros.h>
|
||||
#include <faiss/utils/Heap.h>
|
||||
|
||||
|
||||
@@ -114,7 +115,7 @@ struct BitstringReader {
|
||||
|
||||
|
||||
|
||||
extern size_t hamming_batch_size;
|
||||
FAISS_API extern size_t hamming_batch_size;
|
||||
|
||||
inline int popcount64(uint64_t x) {
|
||||
return __builtin_popcountl(x);
|
||||
|
||||
Reference in New Issue
Block a user