aboutsummaryrefslogtreecommitdiff
path: root/src/model_internal.h
diff options
context:
space:
mode:
authorOnur Gündüz <ogunduz@gmail.com>2026-06-17 01:21:41 +0200
committerOnur Gündüz <ogunduz@gmail.com>2026-06-17 01:21:41 +0200
commite00becb643b3a99de16462b3a032717a93b983d9 (patch)
tree873ad2646b0ef2f07eae5a5a74387d062c77ec0c /src/model_internal.h
parentb4343d6ac1c6cc7a7d228f954220def2f6e6ed67 (diff)
downloadffwd-e00becb643b3a99de16462b3a032717a93b983d9.tar.gz
ffwd-e00becb643b3a99de16462b3a032717a93b983d9.zip
all: accept F16 safetensors weights (widen to F32 at load)
Diffstat (limited to 'src/model_internal.h')
-rw-r--r--src/model_internal.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/model_internal.h b/src/model_internal.h
index f61b069..acbba07 100644
--- a/src/model_internal.h
+++ b/src/model_internal.h
@@ -12,7 +12,8 @@
* 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. */
+ * bytes lie within the mapped file. bf16_ok permits 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,
@@ -20,6 +21,12 @@ 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. */
+embed_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). */
int model_dir_has_late_projection(const char *model_dir);