aboutsummaryrefslogtreecommitdiff
path: root/embed_mlx.h
diff options
context:
space:
mode:
authorOnur Gündüz <ogunduz@gmail.com>2026-06-15 08:40:11 +0200
committerOnur Gündüz <ogunduz@gmail.com>2026-06-15 08:40:11 +0200
commitc4a1c97a09da6d8d88c2ac834bf6234506fc41bc (patch)
tree81ce5675ce886aad0309a41f4d6a696826e0a061 /embed_mlx.h
parentb377ba8656bfb807ed8dda6c9f26942b50ce626d (diff)
downloadffwd-c4a1c97a09da6d8d88c2ac834bf6234506fc41bc.tar.gz
ffwd-c4a1c97a09da6d8d88c2ac834bf6234506fc41bc.zip
chore: run clang-format
Diffstat (limited to 'embed_mlx.h')
-rw-r--r--embed_mlx.h69
1 files changed, 41 insertions, 28 deletions
diff --git a/embed_mlx.h b/embed_mlx.h
index 5f6e2c9..87fbda6 100644
--- a/embed_mlx.h
+++ b/embed_mlx.h
@@ -38,7 +38,7 @@ typedef struct {
*/
EMBED_API embed_mlx_ctx_t *embed_mlx_load(const char *model_dir);
EMBED_API embed_mlx_ctx_t *embed_mlx_load_with_options(const char *model_dir,
- const embed_mlx_options_t *opts);
+ const embed_mlx_options_t *opts);
EMBED_API void embed_mlx_free(embed_mlx_ctx_t *ctx);
@@ -48,8 +48,8 @@ EMBED_API void embed_mlx_free(embed_mlx_ctx_t *ctx);
* scoring, not one pooled document vector.
*/
EMBED_API embed_mlx_late_ctx_t *embed_mlx_late_load(const char *model_dir);
-EMBED_API embed_mlx_late_ctx_t *embed_mlx_late_load_with_options(
- const char *model_dir, const embed_mlx_options_t *opts);
+EMBED_API embed_mlx_late_ctx_t *embed_mlx_late_load_with_options(const char *model_dir,
+ const embed_mlx_options_t *opts);
EMBED_API void embed_mlx_late_free(embed_mlx_late_ctx_t *ctx);
EMBED_API const embed_config_t *embed_mlx_late_config(const embed_mlx_late_ctx_t *ctx);
@@ -62,8 +62,10 @@ EMBED_API int embed_mlx_late_token_dim(const embed_mlx_late_ctx_t *ctx);
* before copying back to CPU memory.
*/
EMBED_API int embed_mlx_late_encode_tokens(embed_mlx_late_ctx_t *ctx,
- const int *token_ids, int n_tokens,
- int normalize, float *out_vectors);
+ const int *token_ids,
+ int n_tokens,
+ int normalize,
+ float *out_vectors);
/*
* Device-resident late-interaction token vectors.
@@ -72,24 +74,27 @@ EMBED_API int embed_mlx_late_encode_tokens(embed_mlx_late_ctx_t *ctx,
* outlive ctx. Copying is optional: MaxSim can consume these handles directly
* and copy back only final candidate scores.
*/
-EMBED_API embed_mlx_late_vectors_t *embed_mlx_late_encode_tokens_device(
- embed_mlx_late_ctx_t *ctx, const int *token_ids, int n_tokens,
- int normalize);
+EMBED_API embed_mlx_late_vectors_t *embed_mlx_late_encode_tokens_device(embed_mlx_late_ctx_t *ctx,
+ const int *token_ids,
+ int n_tokens,
+ int normalize);
EMBED_API void embed_mlx_late_vectors_free(embed_mlx_late_vectors_t *vecs);
EMBED_API int embed_mlx_late_vectors_token_count(const embed_mlx_late_vectors_t *vecs);
EMBED_API int embed_mlx_late_vectors_dim(const embed_mlx_late_vectors_t *vecs);
-EMBED_API int embed_mlx_late_vectors_copy(const embed_mlx_late_vectors_t *vecs,
- float *out_vectors);
+EMBED_API int embed_mlx_late_vectors_copy(const embed_mlx_late_vectors_t *vecs, float *out_vectors);
EMBED_API embed_mlx_late_vectors_t *embed_mlx_late_vectors_concat(
- embed_mlx_late_ctx_t *ctx,
- const embed_mlx_late_vectors_t *const *items, int count);
-EMBED_API embed_mlx_late_vectors_t *embed_mlx_late_vectors_select(
- embed_mlx_late_ctx_t *ctx, const embed_mlx_late_vectors_t *vecs,
- const int *token_indices, int count);
-EMBED_API int embed_mlx_late_maxsim_batch_device(
- embed_mlx_late_ctx_t *ctx, const embed_mlx_late_vectors_t *query,
- const embed_mlx_late_vectors_t *docs, const int *doc_offsets,
- int docs_count, float *scores);
+ embed_mlx_late_ctx_t *ctx, const embed_mlx_late_vectors_t *const *items, int count);
+EMBED_API embed_mlx_late_vectors_t *
+embed_mlx_late_vectors_select(embed_mlx_late_ctx_t *ctx,
+ const embed_mlx_late_vectors_t *vecs,
+ const int *token_indices,
+ int count);
+EMBED_API int embed_mlx_late_maxsim_batch_device(embed_mlx_late_ctx_t *ctx,
+ const embed_mlx_late_vectors_t *query,
+ const embed_mlx_late_vectors_t *docs,
+ const int *doc_offsets,
+ int docs_count,
+ float *scores);
/*
* Compute embedding for token_ids[0..n_tokens-1].
@@ -101,8 +106,10 @@ EMBED_API float *embed_mlx_encode(embed_mlx_ctx_t *ctx, const int *token_ids, in
* Compute one embedding into caller-provided out[hidden_size].
* Returns 0 on success, -1 on error.
*/
-EMBED_API int embed_mlx_encode_into(embed_mlx_ctx_t *ctx, const int *token_ids,
- int n_tokens, float *out_embedding);
+EMBED_API int embed_mlx_encode_into(embed_mlx_ctx_t *ctx,
+ const int *token_ids,
+ int n_tokens,
+ float *out_embedding);
/*
* Compute a true padded dense batch on MLX.
@@ -111,24 +118,30 @@ EMBED_API int embed_mlx_encode_into(embed_mlx_ctx_t *ctx, const int *token_ids,
* Pooling and attention masking follow the loaded model configuration.
* Returns 0 on success, -1 on error.
*/
-EMBED_API int embed_mlx_encode_batch(embed_mlx_ctx_t *ctx, const embed_input_t *inputs,
- int batch, float *out_embeddings);
+EMBED_API int embed_mlx_encode_batch(embed_mlx_ctx_t *ctx,
+ const embed_input_t *inputs,
+ int batch,
+ float *out_embeddings);
/*
* Run one contextual sequence and pool selected token spans.
* Returns 0 on success, -1 on error.
*/
-EMBED_API int embed_mlx_encode_spans(embed_mlx_ctx_t *ctx, const int *token_ids,
- int n_tokens, const embed_span_t *spans,
- int n_spans, float *out_embeddings);
+EMBED_API int embed_mlx_encode_spans(embed_mlx_ctx_t *ctx,
+ const int *token_ids,
+ int n_tokens,
+ const embed_span_t *spans,
+ int n_spans,
+ float *out_embeddings);
/*
* Run a padded dense contextual document batch and pool every selected span.
* out_embeddings contains spans in document order.
*/
EMBED_API int embed_mlx_encode_spans_batch(embed_mlx_ctx_t *ctx,
- const embed_context_input_t *inputs, int batch,
- float *out_embeddings);
+ const embed_context_input_t *inputs,
+ int batch,
+ float *out_embeddings);
/* Get the config (so embed_cli.c can read hidden_size etc.) */
EMBED_API const embed_config_t *embed_mlx_config(const embed_mlx_ctx_t *ctx);