aboutsummaryrefslogtreecommitdiff
path: root/embed_mlx.h
diff options
context:
space:
mode:
authorOnur Gündüz <ogunduz@gmail.com>2026-06-11 23:40:01 +0200
committerOnur Gündüz <ogunduz@gmail.com>2026-06-14 08:27:10 +0200
commit978f4f7969190265e127e8a3d704bb173fbd171c (patch)
tree42f3a89e1ecb481ef0e5196a775ea37edb4b98f7 /embed_mlx.h
parentd9ea2cea7dfa1eb25526a3e9b729beda5ccb006f (diff)
downloadffwd-978f4f7969190265e127e8a3d704bb173fbd171c.tar.gz
ffwd-978f4f7969190265e127e8a3d704bb173fbd171c.zip
chore: rename project
Diffstat (limited to 'embed_mlx.h')
-rw-r--r--embed_mlx.h88
1 files changed, 44 insertions, 44 deletions
diff --git a/embed_mlx.h b/embed_mlx.h
index be467d0..267c454 100644
--- a/embed_mlx.h
+++ b/embed_mlx.h
@@ -4,17 +4,17 @@
* Uses Apple's mlx-c to run the transformer on Metal.
*/
-#ifndef PPLX_EMBED_MLX_H
-#define PPLX_EMBED_MLX_H
+#ifndef EMBED_MLX_H
+#define EMBED_MLX_H
/* Public-API export annotation. The libraries are built with
- * -fvisibility=hidden, so only declarations carrying PPLX_API are exported
+ * -fvisibility=hidden, so only declarations carrying EMBED_API are exported
* from the shared library; everything else stays internal. */
-#ifndef PPLX_API
+#ifndef EMBED_API
#if defined(__GNUC__)
-#define PPLX_API __attribute__((visibility("default")))
+#define EMBED_API __attribute__((visibility("default")))
#else
-#define PPLX_API
+#define EMBED_API
#endif
#endif
@@ -23,37 +23,37 @@
#include "embed.h"
/* Opaque MLX model context */
-typedef struct pplx_mlx_ctx pplx_mlx_ctx_t;
-typedef struct pplx_mlx_late_ctx pplx_mlx_late_ctx_t;
-typedef struct pplx_mlx_late_vectors pplx_mlx_late_vectors_t;
+typedef struct embed_mlx_ctx embed_mlx_ctx_t;
+typedef struct embed_mlx_late_ctx embed_mlx_late_ctx_t;
+typedef struct embed_mlx_late_vectors embed_mlx_late_vectors_t;
typedef struct {
int quantize_bits; /* 0 disables; currently 8 */
int quantize_group_size; /* default 64 when quantize_bits is set */
-} pplx_mlx_options_t;
+} embed_mlx_options_t;
/*
* Load model into MLX arrays from safetensors + config.json.
* Returns NULL on error.
*/
-PPLX_API pplx_mlx_ctx_t *pplx_mlx_load(const char *model_dir);
-PPLX_API pplx_mlx_ctx_t *pplx_mlx_load_with_options(const char *model_dir,
- const pplx_mlx_options_t *opts);
+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);
-PPLX_API void pplx_mlx_free(pplx_mlx_ctx_t *ctx);
+EMBED_API void embed_mlx_free(embed_mlx_ctx_t *ctx);
/*
* Late-interaction MLX path. This is separate from pooled embeddings because
* late snapshots produce one projected token vector per input token for MaxSim
* scoring, not one pooled document vector.
*/
-PPLX_API pplx_mlx_late_ctx_t *pplx_mlx_late_load(const char *model_dir);
-PPLX_API pplx_mlx_late_ctx_t *pplx_mlx_late_load_with_options(
- const char *model_dir, const pplx_mlx_options_t *opts);
-PPLX_API void pplx_mlx_late_free(pplx_mlx_late_ctx_t *ctx);
+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 void embed_mlx_late_free(embed_mlx_late_ctx_t *ctx);
-PPLX_API const pplx_config_t *pplx_mlx_late_config(const pplx_mlx_late_ctx_t *ctx);
-PPLX_API int pplx_mlx_late_token_dim(const pplx_mlx_late_ctx_t *ctx);
+EMBED_API const embed_config_t *embed_mlx_late_config(const embed_mlx_late_ctx_t *ctx);
+EMBED_API int embed_mlx_late_token_dim(const embed_mlx_late_ctx_t *ctx);
/*
* Encode token_ids into out_vectors[n_tokens, token_dim].
@@ -61,7 +61,7 @@ PPLX_API int pplx_mlx_late_token_dim(const pplx_mlx_late_ctx_t *ctx);
* If normalize is non-zero, every token vector is L2-normalized on device
* before copying back to CPU memory.
*/
-PPLX_API int pplx_mlx_late_encode_tokens(pplx_mlx_late_ctx_t *ctx,
+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);
@@ -72,36 +72,36 @@ PPLX_API int pplx_mlx_late_encode_tokens(pplx_mlx_late_ctx_t *ctx,
* outlive ctx. Copying is optional: MaxSim can consume these handles directly
* and copy back only final candidate scores.
*/
-PPLX_API pplx_mlx_late_vectors_t *pplx_mlx_late_encode_tokens_device(
- pplx_mlx_late_ctx_t *ctx, const int *token_ids, int n_tokens,
+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);
-PPLX_API void pplx_mlx_late_vectors_free(pplx_mlx_late_vectors_t *vecs);
-PPLX_API int pplx_mlx_late_vectors_token_count(const pplx_mlx_late_vectors_t *vecs);
-PPLX_API int pplx_mlx_late_vectors_dim(const pplx_mlx_late_vectors_t *vecs);
-PPLX_API int pplx_mlx_late_vectors_copy(const pplx_mlx_late_vectors_t *vecs,
+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);
-PPLX_API pplx_mlx_late_vectors_t *pplx_mlx_late_vectors_concat(
- pplx_mlx_late_ctx_t *ctx,
- const pplx_mlx_late_vectors_t *const *items, int count);
-PPLX_API pplx_mlx_late_vectors_t *pplx_mlx_late_vectors_select(
- pplx_mlx_late_ctx_t *ctx, const pplx_mlx_late_vectors_t *vecs,
+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);
-PPLX_API int pplx_mlx_late_maxsim_batch_device(
- pplx_mlx_late_ctx_t *ctx, const pplx_mlx_late_vectors_t *query,
- const pplx_mlx_late_vectors_t *docs, const int *doc_offsets,
+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].
* Returns malloc'd float[hidden_size] (caller frees). NULL on error.
*/
-PPLX_API float *pplx_mlx_embed(pplx_mlx_ctx_t *ctx, const int *token_ids, int n_tokens);
+EMBED_API float *embed_mlx_encode(embed_mlx_ctx_t *ctx, const int *token_ids, int n_tokens);
/*
* Compute one embedding into caller-provided out[hidden_size].
* Returns 0 on success, -1 on error.
*/
-PPLX_API int pplx_mlx_embed_into(pplx_mlx_ctx_t *ctx, const int *token_ids,
+EMBED_API int embed_mlx_encode_into(embed_mlx_ctx_t *ctx, const int *token_ids,
int n_tokens, float *out_embedding);
/*
@@ -111,26 +111,26 @@ PPLX_API int pplx_mlx_embed_into(pplx_mlx_ctx_t *ctx, const int *token_ids,
* Padded tokens are masked out of attention keys and mean pooling.
* Returns 0 on success, -1 on error.
*/
-PPLX_API int pplx_mlx_embed_batch(pplx_mlx_ctx_t *ctx, const pplx_input_t *inputs,
+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.
*/
-PPLX_API int pplx_mlx_embed_spans(pplx_mlx_ctx_t *ctx, const int *token_ids,
- int n_tokens, const pplx_span_t *spans,
+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.
*/
-PPLX_API int pplx_mlx_embed_spans_batch(pplx_mlx_ctx_t *ctx,
- const pplx_context_input_t *inputs, int batch,
+EMBED_API int embed_mlx_encode_spans_batch(embed_mlx_ctx_t *ctx,
+ const embed_context_input_t *inputs, int batch,
float *out_embeddings);
/* Get the config (so embed_cli.c can read hidden_size etc.) */
-PPLX_API const pplx_config_t *pplx_mlx_config(const pplx_mlx_ctx_t *ctx);
+EMBED_API const embed_config_t *embed_mlx_config(const embed_mlx_ctx_t *ctx);
-#endif /* PPLX_EMBED_MLX_H */
+#endif /* EMBED_MLX_H */