Add VectorTransform read from filename to the C API (#3970)
Summary: This adds read_VectorTransform to the C API. This is helpful for independently loading a vector transform rather than as an IndexPreTransform. Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3970 Reviewed By: asadoughi Differential Revision: D65192203 Pulled By: junjieqi fbshipit-source-id: 949ae875924b9f3558d7a9f43c4f2aa8ae705f02pull/4011/head
parent
9766d64dde
commit
2c961cc308
|
@ -14,6 +14,7 @@
|
|||
|
||||
using faiss::Index;
|
||||
using faiss::IndexBinary;
|
||||
using faiss::VectorTransform;
|
||||
|
||||
int faiss_write_index(const FaissIndex* idx, FILE* f) {
|
||||
try {
|
||||
|
@ -83,3 +84,13 @@ 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
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <stdio.h>
|
||||
#include "IndexBinary_c.h"
|
||||
#include "Index_c.h"
|
||||
#include "VectorTransform_c.h"
|
||||
#include "faiss_c.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -71,6 +72,13 @@ 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
|
||||
|
|
Loading…
Reference in New Issue