diff options
| author | Onur Gündüz <ogunduz@gmail.com> | 2026-03-28 20:01:21 +0100 |
|---|---|---|
| committer | Onur Gündüz <ogunduz@gmail.com> | 2026-03-28 20:01:21 +0100 |
| commit | 34e9eefde7870edcc318209738cabb17c71b50ed (patch) | |
| tree | 470923a965c647de8a827ffbeea1e87a732360a7 /pplx_embed_mlx.h | |
| parent | 0128ed8d9d7e289b9b6aae752d7e820f36bd26e1 (diff) | |
| download | ffwd-34e9eefde7870edcc318209738cabb17c71b50ed.tar.gz ffwd-34e9eefde7870edcc318209738cabb17c71b50ed.zip | |
Init
Diffstat (limited to 'pplx_embed_mlx.h')
| -rw-r--r-- | pplx_embed_mlx.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/pplx_embed_mlx.h b/pplx_embed_mlx.h new file mode 100644 index 0000000..5327fd0 --- /dev/null +++ b/pplx_embed_mlx.h @@ -0,0 +1,35 @@ +/* + * pplx_embed_mlx.h - MLX GPU backend for pplx-embed inference + * + * Uses Apple's mlx-c to run the transformer on Metal GPU. + * All operations run on the GPU default stream; the result is copied + * back to CPU as a float* embedding. + */ + +#ifndef PPLX_EMBED_MLX_H +#define PPLX_EMBED_MLX_H + +#include <stddef.h> +#include <stdint.h> + +/* Opaque MLX model context */ +typedef struct pplx_mlx_ctx pplx_mlx_ctx_t; + +/* + * Load model into MLX arrays from safetensors in model_dir. + * Returns NULL on error. + */ +pplx_mlx_ctx_t *pplx_mlx_load(const char *model_dir); + +/* + * Free all MLX resources. + */ +void pplx_mlx_free(pplx_mlx_ctx_t *ctx); + +/* + * Compute embedding for token_ids[0..n_tokens-1]. + * Returns malloc'd float[1024] (caller frees). NULL on error. + */ +float *pplx_mlx_embed(pplx_mlx_ctx_t *ctx, const int *token_ids, int n_tokens); + +#endif /* PPLX_EMBED_MLX_H */ |
