diff options
| author | Onur Gündüz <ogunduz@gmail.com> | 2026-06-16 17:21:54 +0200 |
|---|---|---|
| committer | Onur Gündüz <ogunduz@gmail.com> | 2026-06-16 17:49:33 +0200 |
| commit | e54c07a3f54e7f5825bf27d1a9a6dbb5fb0baa8c (patch) | |
| tree | 8418dbc57529a6d8ae822b29f813effe6b6da231 /src/engine.h | |
| parent | 3904a33e4416c35a48e8dd7c242a137a2cc17871 (diff) | |
| download | ffwd-e54c07a3f54e7f5825bf27d1a9a6dbb5fb0baa8c.tar.gz ffwd-e54c07a3f54e7f5825bf27d1a9a6dbb5fb0baa8c.zip | |
cpu: split embed.c into model.c and forward.c
Diffstat (limited to '')
| -rw-r--r-- | src/model_internal.h (renamed from src/engine.h) | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/engine.h b/src/model_internal.h index abdb0c7..f61b069 100644 --- a/src/engine.h +++ b/src/model_internal.h @@ -1,14 +1,15 @@ -#ifndef EMBED_ENGINE_H -#define EMBED_ENGINE_H +#ifndef EMBED_MODEL_INTERNAL_H +#define EMBED_MODEL_INTERNAL_H #include "internal.h" #include "alloc.h" -/* Cross-file declarations internal to the CPU engine. These functions are not - * part of the public API (embed.h) and carry no EMBED_API visibility; they are - * shared between the engine translation units (model loading, the forward pass, - * and late interaction) that used to live in one file. The frontends and the - * GPU backends do not include this header. */ +/* Cross-file function declarations private to the CPU model code. The companion + * to internal.h: that header holds the shared struct definitions, this one the + * shared functions. None are part of the public API (embed.h) and none carry + * EMBED_API visibility; they are shared between the translation units (model + * loading, the forward pass, and late interaction) that used to live in one + * file. The frontends and the GPU backends do not include this header. */ /* Validate that a safetensor matches an expected dtype/rank/shape and that its * bytes lie within the mapped file. bf16_ok permits BF16 in addition to F32. */ @@ -27,6 +28,14 @@ int model_dir_has_late_projection(const char *model_dir); embed_model_t * model_load_range_ex(const char *model_dir, int layer_start, int layer_end, int allow_late); +/* Workspace scratch growth, lazy per forward call. Defined in model.c beside the + * workspace lifecycle (embed_workspace_nbytes mirrors their sizing); called from + * the forward pass in forward.c. */ +int ensure_buffers(embed_workspace_t *ws, const embed_config_t *c, int seq); +void ensure_attention_scores(embed_workspace_t *ws, const int *offsets, int batch); +int ensure_rope_cache(embed_workspace_t *ws, const embed_config_t *cfg, int n_pos); +int ensure_offsets(embed_workspace_t *ws, int batch); + /* y[seq,out] = x[seq,in] @ w^T, no bias; dispatches F32/BF16 paths. Shared by * the forward pass and the late projection. */ void linear_nobias_weight(embed_workspace_t *ws, @@ -57,4 +66,4 @@ int forward_packed_inplace(const embed_model_t *model, int max_seq, int apply_final_norm); -#endif /* EMBED_ENGINE_H */ +#endif /* EMBED_MODEL_INTERNAL_H */ |
