Resolved some issues

This commit is contained in:
Kinar
2023-10-05 03:54:54 -07:00
parent 753ba916a1
commit 92e13d43e4
7 changed files with 18 additions and 11 deletions
@@ -100,13 +100,13 @@ int CppTextEmbedderClose(void* embedder, char** error_msg) {
extern "C" {
void* text_embedder_create(struct TextEmbedderOptions* options,
char** error_msg) {
char** error_msg) {
return mediapipe::tasks::c::text::text_embedder::CppTextEmbedderCreate(
*options, error_msg);
}
int text_embedder_embed(void* embedder, const char* utf8_str,
TextEmbedderResult* result, char** error_msg) {
TextEmbedderResult* result, char** error_msg) {
return mediapipe::tasks::c::text::text_embedder::CppTextEmbedderEmbed(
embedder, utf8_str, result, error_msg);
}
@@ -36,22 +36,22 @@ struct TextEmbedderOptions {
// file with metadata, accelerator options, op resolver, etc.
struct BaseOptions base_options;
// Options for configuring the embedder behavior, such as score threshold,
// number of results, etc.
// Options for configuring the embedder behavior, such as l2_normalize
// and quantize.
struct EmbedderOptions embedder_options;
};
// Creates a TextEmbedder from the provided `options`.
// Returns a pointer to the text embedder on success.
// If an error occurs, returns `nullptr` and sets the error parameter to an
// an error message (if `error_msg` is not nullptr). You must free the memory
// an error message (if `error_msg` is not `nullptr`). You must free the memory
// allocated for the error message.
MP_EXPORT void* text_embedder_create(struct TextEmbedderOptions* options,
char** error_msg = nullptr);
// Performs embedding extraction on the input `text`. Returns `0` on success.
// If an error occurs, returns an error code and sets the error parameter to an
// an error message (if `error_msg` is not nullptr). You must free the memory
// an error message (if `error_msg` is not `nullptr`). You must free the memory
// allocated for the error message.
MP_EXPORT int text_embedder_embed(void* embedder, const char* utf8_str,
TextEmbedderResult* result,
@@ -63,7 +63,7 @@ MP_EXPORT void text_embedder_close_result(TextEmbedderResult* result);
// Shuts down the TextEmbedder when all the work is done. Frees all memory.
// If an error occurs, returns an error code and sets the error parameter to an
// an error message (if `error_msg` is not nullptr). You must free the memory
// an error message (if `error_msg` is not `nullptr`). You must free the memory
// allocated for the error message.
MP_EXPORT int text_embedder_close(void* embedder,
char** error_msg = nullptr);
@@ -44,8 +44,7 @@ TEST(TextEmbedderTest, SmokeTest) {
/* base_options= */ {/* model_asset_buffer= */ nullptr,
/* model_asset_path= */ model_path.c_str()},
/* embedder_options= */
{/* l2_normalize= */ false,
/* quantize= */ true},
{/* l2_normalize= */ false, /* quantize= */ true},
};
void* embedder = text_embedder_create(&options);