Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 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
9 changes: 9 additions & 0 deletions c_api/index_io_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

using faiss::Index;
using faiss::IndexBinary;
using faiss::VectorTransform;

int faiss_write_index(const FaissIndex* idx, FILE* f) {
try {
Expand Down Expand Up @@ -83,3 +84,11 @@ int faiss_read_index_binary_fname(
}
CATCH_AND_HANDLE
}

int faiss_read_VectorTransform_fname(const char* fname, FaissVectorTransform** p_out) {
try {
auto out = faiss::read_VectorTransform(fname);
*p_out = reinterpret_cast<FaissVectorTransform*>(out);
}
CATCH_AND_HANDLE
}
6 changes: 6 additions & 0 deletions c_api/index_io_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "IndexBinary_c.h"
#include "Index_c.h"
#include "faiss_c.h"
#include "VectorTransform_c.h"

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -71,6 +72,11 @@ int faiss_read_index_binary_fname(
const char* fname,
int io_flags,
FaissIndexBinary** p_out);

/** Read vector transform from a file.
* This is equivalent to `faiss:read_VectorTransform` when a file path is given.
*/
int faiss_read_VectorTransform_fname(const char* fname, FaissVectorTransform** p_out);
#ifdef __cplusplus
}
#endif
Expand Down