diff options
| author | Onur Gündüz <ogunduz@gmail.com> | 2026-09-29 13:11:00 +0200 |
|---|---|---|
| committer | Onur Gündüz <ogunduz@gmail.com> | 2026-09-29 13:11:00 +0200 |
| commit | 37cbaef9ceb828c667da8f398027ba5415ee7475 (patch) | |
| tree | 6103e92a9030766e78a35df00f7a1155d0d0ecf5 /libffwd/model_blas.c | |
| parent | cf7d8169ec12cb3adf90d4ff78b3257e74985302 (diff) | |
| download | langdet-37cbaef9ceb828c667da8f398027ba5415ee7475.tar.gz langdet-37cbaef9ceb828c667da8f398027ba5415ee7475.zip | |
Rename CPU library API and sources to langdet
Diffstat (limited to 'libffwd/model_blas.c')
| -rw-r--r-- | libffwd/model_blas.c | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/libffwd/model_blas.c b/libffwd/model_blas.c deleted file mode 100644 index 409ba66..0000000 --- a/libffwd/model_blas.c +++ /dev/null @@ -1,68 +0,0 @@ -#include "model_internal.h" -#include "kernels.h" - -#include <stdlib.h> - -ffwd_workspace_t *ffwd_workspace_new(const ffwd_model_t *model) { - if (!model) - return NULL; - ffwd_workspace_t *ws = (ffwd_workspace_t *)calloc(1, sizeof(ffwd_workspace_t)); - if (!ws) - return NULL; - ws->model = model; - return ws; -} - -void ffwd_workspace_free(ffwd_workspace_t *ws) { - if (!ws) - return; - free(ws->x); - free(ws->q); - free(ws->k); - free(ws->v); - free(ws->attn_out); - free(ws->proj_out); - free(ws->ffn_up); - free(ws->attn_scores); - free(ws); -} - -int ensure_buffers(ffwd_workspace_t *ws, const ffwd_config_t *c, int seq) { - if (seq <= ws->buf_seq_cap) - return 0; - - int cap; - if (grow_cap(ws->buf_seq_cap, seq, &cap) != 0) - return -1; - -#define R(ptr, n) \ - do { \ - if (realloc_floats_2d(&(ptr), cap, (n)) != 0) \ - return -1; \ - } while (0) - - R(ws->x, c->hidden_size); - R(ws->q, c->hidden_size); - R(ws->k, c->hidden_size); - R(ws->v, c->hidden_size); - R(ws->attn_out, c->hidden_size); - R(ws->proj_out, c->hidden_size); - R(ws->ffn_up, c->intermediate_size); - -#undef R - - ws->buf_seq_cap = cap; - return 0; -} - -void ensure_attention_scores(ffwd_workspace_t *ws, const int *offsets, int batch) { - size_t bytes = bidirectional_gqa_attention_packed_scratch_bytes(offsets, batch); - if (bytes <= ws->attn_scores_bytes) - return; - - void *p = realloc(ws->attn_scores, bytes); - if (!p) - return; - ws->attn_scores = (float *)p; - ws->attn_scores_bytes = bytes; -} |
