diff options
| author | Onur Gündüz <ogunduz@gmail.com> | 2026-06-27 00:58:05 +0200 |
|---|---|---|
| committer | Onur Gündüz <ogunduz@gmail.com> | 2026-06-27 01:03:41 +0200 |
| commit | af55803d0dff9eb692c760c8d486e736c945061d (patch) | |
| tree | 0875a1112bf98304e445e0544c4309670d6f4769 /libffwd/model_internal.h | |
| parent | 0f861b7f3098750ddee4f6570f3be228d1da5320 (diff) | |
| download | ffwd-af55803d0dff9eb692c760c8d486e736c945061d.tar.gz ffwd-af55803d0dff9eb692c760c8d486e736c945061d.zip | |
chore: clean up comment formatting and wording
Diffstat (limited to 'libffwd/model_internal.h')
| -rw-r--r-- | libffwd/model_internal.h | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/libffwd/model_internal.h b/libffwd/model_internal.h index 97de064..b828e67 100644 --- a/libffwd/model_internal.h +++ b/libffwd/model_internal.h @@ -1,19 +1,24 @@ +/* Cross-file declarations private to CPU model code. + * + * model_types.h holds the shared struct definitions; this header holds the + * shared functions. + * + * These are not part of the public API (ffwd.h) and do not use FFWD_API + * visibility. They are shared between translation units that used to be one + * file: model loading, the forward pass, and late interaction. + * + * Frontends and GPU backends do not include this header. + */ + #ifndef FFWD_MODEL_INTERNAL_H #define FFWD_MODEL_INTERNAL_H #include "model_types.h" #include "alloc.h" -/* Cross-file function declarations private to the CPU model code. The companion - * to model_types.h: that header holds the shared struct definitions, this one the - * shared functions. None are part of the public API (ffwd.h) and none carry - * FFWD_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 either 16-bit float format - * (BF16 or F16) in addition to F32. */ +/* Validate that a safetensor has the expected dtype, rank, and shape, and that + * its bytes are within the mapped file. bf16_ok also allows either 16-bit float + * format, BF16 or F16, in addition to F32. */ int tensor_has_supported_shape(const safetensors_file_t *sf, const safetensor_t *t, const char *name, @@ -21,10 +26,14 @@ int tensor_has_supported_shape(const safetensors_file_t *sf, int ndim, int bf16_ok); -/* Build a weight ref from a located tensor: F32/BF16 borrow the mmap, F16 is - * widened to an owned F32 buffer (no fused F16 kernel). Shared by the model - * loader and the late-interaction projection loader; the owner frees ref.data - * when ref.owned is set. Returns ref.data == NULL on allocation failure. */ +/* Build a weight ref from a located tensor. + * F32/BF16 borrow the mmap; F16 is widened to an owned F32 buffer because there + * is no fused F16 kernel. + * + * Shared by the model loader and late-interaction projection loader. + * The owner frees ref.data when ref.owned is set. + * + * Returns ref.data == NULL on allocation failure. */ ffwd_weight_ref_t weight_ref_from_tensor(const safetensors_file_t *sf, const safetensor_t *t); /* True if model_dir carries a 1_Dense projection (a late-interaction model). */ @@ -35,9 +44,9 @@ int model_dir_has_late_projection(const char *model_dir); ffwd_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 (ffwd_workspace_nbytes mirrors their sizing); called from - * the forward pass in forward.c. */ +/* Workspace scratch grows lazily per forward call. + * Defined in model.c beside the workspace lifecycle. ffwd_workspace_nbytes mirrors this sizing. + * Called from the forward pass in forward.c. */ int ensure_buffers(ffwd_workspace_t *ws, const ffwd_config_t *c, int seq); void ensure_attention_scores(ffwd_workspace_t *ws, const int *offsets, int batch); int ensure_rope_cache(ffwd_workspace_t *ws, const ffwd_config_t *cfg, int n_pos); |
