Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add VectorTransform read from filename to the C API #3970

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions c_api/index_io_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

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

int faiss_write_index(const FaissIndex* idx, FILE* f) {
try {
Expand Down Expand Up @@ -84,3 +85,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 @@ -16,6 +16,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 @@ -72,6 +73,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