diff options
| author | Onur Gündüz <ogunduz@gmail.com> | 2026-06-20 20:36:55 +0200 |
|---|---|---|
| committer | Onur Gündüz <ogunduz@gmail.com> | 2026-06-21 06:00:26 +0200 |
| commit | 6652fcbc653d84e75cb5c08c5f5edf52263ed50f (patch) | |
| tree | 1ccffa48e1dc86c59c61dcd4672ffedcf1e0c873 /tests/test_xlm_roberta.c | |
| parent | dbdf714bb57578431924e5d069089bdfd9f4c604 (diff) | |
| download | ffwd-6652fcbc653d84e75cb5c08c5f5edf52263ed50f.tar.gz ffwd-6652fcbc653d84e75cb5c08c5f5edf52263ed50f.zip | |
tests: upgrade unit tests and add integration/parity tests
Diffstat (limited to 'tests/test_xlm_roberta.c')
| -rw-r--r-- | tests/test_xlm_roberta.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/tests/test_xlm_roberta.c b/tests/test_xlm_roberta.c index 29e05f7..4370855 100644 --- a/tests/test_xlm_roberta.c +++ b/tests/test_xlm_roberta.c @@ -1,6 +1,6 @@ /* tests/test_xlm_roberta.c - hermetic XLM-R/RoBERTa bridge checks. */ -#include "embed.h" +#include "internal.h" #include "tiny_model.h" #include <stdio.h> @@ -50,47 +50,46 @@ static int write_fixture(const char *dir) { }; snprintf(path, sizeof(path), "%s/model.safetensors", dir); return tm_write_safetensors_with_prefix(path, "F32", specs, - (int)(sizeof(specs) / sizeof(specs[0])), - "roberta."); + (int)(sizeof(specs) / sizeof(specs[0])), "roberta."); } int main(void) { const char *tmp = getenv("TMPDIR") ? getenv("TMPDIR") : "/tmp"; char dir[1024]; - snprintf(dir, sizeof(dir), "%s/embed-xlm-roberta-test-XXXXXX", tmp); + snprintf(dir, sizeof(dir), "%s/ffwd-xlm-roberta-test-XXXXXX", tmp); if (!mkdtemp(dir) || write_fixture(dir) != 0) { fprintf(stderr, "fixture creation failed\n"); return 2; } - embed_model_t *model = embed_model_load(dir); - embed_workspace_t *ws = embed_workspace_new(model); - const embed_config_t *cfg = embed_model_config(model); + ffwd_model_t *model = ffwd_model_load(dir); + ffwd_workspace_t *ws = ffwd_workspace_new(model); + const ffwd_config_t *cfg = ffwd_model_config(model); if (!model || !ws || !cfg) { fprintf(stderr, "model setup failed\n"); return 1; } - if (cfg->family != EMBED_FAMILY_BERT || cfg->position_id_offset != 2 || - cfg->type_vocab_size != 1 || cfg->pooling_mode != EMBED_POOL_MEAN || - cfg->attention_mode != EMBED_ATTENTION_BIDIRECTIONAL) { + if (cfg->family != FFWD_FAMILY_BERT || cfg->position_id_offset != 2 || + cfg->type_vocab_size != 1 || cfg->pooling_mode != FFWD_POOL_MEAN || + cfg->attention_mode != FFWD_ATTENTION_BIDIRECTIONAL) { fprintf(stderr, "XLM-R config bridge wrong\n"); return 1; } float out[4]; int ids_ok[] = {0, 4, 5, 6, 7, 2}; - if (embed_model_encode_into(model, ws, ids_ok, 6, out) != 0) { + if (ffwd_model_encode_into(model, ws, ids_ok, 6, out) != 0) { fprintf(stderr, "XLM-R forward failed at max valid position\n"); return 1; } int ids_too_long[] = {0, 4, 5, 6, 7, 8, 2}; - if (embed_model_encode_into(model, ws, ids_too_long, 7, out) == 0) { + if (ffwd_model_encode_into(model, ws, ids_too_long, 7, out) == 0) { fprintf(stderr, "XLM-R position overflow was accepted\n"); return 1; } - embed_workspace_free(ws); - embed_model_free(model); + ffwd_workspace_free(ws); + ffwd_model_free(model); puts("ok: XLM-R config, roberta prefix, type_vocab_size=1, position offset"); return 0; } |
