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/forward.c | |
| parent | cf7d8169ec12cb3adf90d4ff78b3257e74985302 (diff) | |
| download | langdet-37cbaef9ceb828c667da8f398027ba5415ee7475.tar.gz langdet-37cbaef9ceb828c667da8f398027ba5415ee7475.zip | |
Rename CPU library API and sources to langdet
Diffstat (limited to '')
| -rw-r--r-- | liblangdet/forward.c (renamed from libffwd/forward.c) | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/libffwd/forward.c b/liblangdet/forward.c index b314642..14b1327 100644 --- a/libffwd/forward.c +++ b/liblangdet/forward.c @@ -14,16 +14,16 @@ static void add_bias_rows(float *x, const float *bias, int rows, int dim) { } } -int ffwd_model_encode_into(const ffwd_model_t *model, - ffwd_workspace_t *ws, +int langdet_model_encode_into(const langdet_model_t *model, + langdet_workspace_t *ws, const int *token_ids, int n_tokens, float *out_embedding) { if (!model || !ws || ws->model != model || !token_ids || n_tokens <= 0 || !out_embedding) return -1; - const ffwd_config_t *cfg = &model->config; - const ffwd_weights_t *w = &model->weights; + const langdet_config_t *cfg = &model->config; + const langdet_weights_t *w = &model->weights; int hidden = cfg->hidden_size; int n_heads = cfg->n_heads; int head_dim = cfg->head_dim; @@ -32,7 +32,7 @@ int ffwd_model_encode_into(const ffwd_model_t *model, if (n_tokens > cfg->max_position_embeddings - cfg->position_id_offset) { fprintf(stderr, - "ffwd: sequence length %d plus position offset %d exceeds max_position_embeddings " + "langdet: sequence length %d plus position offset %d exceeds max_position_embeddings " "%d\n", n_tokens, cfg->position_id_offset, cfg->max_position_embeddings); return -1; @@ -50,7 +50,7 @@ int ffwd_model_encode_into(const ffwd_model_t *model, for (int i = 0; i < n_tokens; i++) { int id = token_ids[i]; if (id < 0 || id >= cfg->vocab_size) { - fprintf(stderr, "ffwd: invalid token id %d at position %d\n", id, i); + fprintf(stderr, "langdet: invalid token id %d at position %d\n", id, i); return -1; } float *row = x + (size_t)i * hidden; @@ -59,12 +59,12 @@ int ffwd_model_encode_into(const ffwd_model_t *model, add_inplace(row, w->position_embeddings + (size_t)pos * hidden, hidden); add_inplace(row, w->token_type_embeddings, hidden); } - layer_norm(x, x, w->ffwd_ln_w, w->ffwd_ln_b, n_tokens, hidden, eps); + layer_norm(x, x, w->langdet_ln_w, w->langdet_ln_b, n_tokens, hidden, eps); float scale = 1.0f / sqrtf((float)head_dim); for (int layer = 0; layer < cfg->n_layers; layer++) { - const ffwd_layer_t *l = &w->layers[layer]; + const langdet_layer_t *l = &w->layers[layer]; linear_nobias(q_buf, x, l->wq, n_tokens, hidden, hidden); linear_nobias(k_buf, x, l->wk, n_tokens, hidden, hidden); |
