From 7a88087ba0b5b1b388234f3d2a907673c63bd8cb Mon Sep 17 00:00:00 2001 From: Onur Gündüz Date: Wed, 20 May 2026 05:26:35 +0200 Subject: all: support batched embedding attention --- pplx_embed_mlx.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'pplx_embed_mlx.h') diff --git a/pplx_embed_mlx.h b/pplx_embed_mlx.h index a1544ef..e528367 100644 --- a/pplx_embed_mlx.h +++ b/pplx_embed_mlx.h @@ -28,6 +28,23 @@ void pplx_mlx_free(pplx_mlx_ctx_t *ctx); */ float *pplx_mlx_embed(pplx_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. + */ +int pplx_mlx_embed_into(pplx_mlx_ctx_t *ctx, const int *token_ids, + int n_tokens, float *out_embedding); + +/* + * Compute a true padded dense batch on MLX. + * + * out_embeddings is caller-provided [batch, hidden_size]. + * Padded tokens are masked out of attention keys and mean pooling. + * Returns 0 on success, -1 on error. + */ +int pplx_mlx_embed_batch(pplx_mlx_ctx_t *ctx, const pplx_input_t *inputs, + int batch, float *out_embeddings); + /* Get the config (so main.c can read hidden_size etc.) */ const pplx_config_t *pplx_mlx_config(const pplx_mlx_ctx_t *ctx); -- cgit v1.3.1