aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorOnur Gündüz <ogunduz@gmail.com>2026-06-25 17:58:46 +0200
committerOnur Gündüz <ogunduz@gmail.com>2026-06-25 17:58:46 +0200
commitf7ef995ff54da671f9d7665b3d92ff25934c1e8b (patch)
tree1401d04c0f464b32bffd63f787a63a82c6959e97 /tests
parent417f861f3661c2253258b5683a627d961e81fc68 (diff)
downloadffwd-f7ef995ff54da671f9d7665b3d92ff25934c1e8b.tar.gz
ffwd-f7ef995ff54da671f9d7665b3d92ff25934c1e8b.zip
chore: run clang-format
Diffstat (limited to 'tests')
-rw-r--r--tests/test_cls.c4
-rw-r--r--tests/test_late.c28
-rw-r--r--tests/test_qwen3.c5
-rw-r--r--tests/test_workspace.c4
4 files changed, 19 insertions, 22 deletions
diff --git a/tests/test_cls.c b/tests/test_cls.c
index 79db064..b6e2dfb 100644
--- a/tests/test_cls.c
+++ b/tests/test_cls.c
@@ -37,8 +37,8 @@ int main(void) {
fprintf(stderr, "model setup failed\n");
return 1;
}
- if (cfg->pooling_mode != FFWD_POOL_CLS ||
- cfg->attention_mode != FFWD_ATTENTION_BIDIRECTIONAL || !cfg->normalize_embeddings) {
+ if (cfg->pooling_mode != FFWD_POOL_CLS || cfg->attention_mode != FFWD_ATTENTION_BIDIRECTIONAL ||
+ !cfg->normalize_embeddings) {
fprintf(stderr, "CLS pooling metadata was not detected\n");
return 1;
}
diff --git a/tests/test_late.c b/tests/test_late.c
index fccd040..37a1bf1 100644
--- a/tests/test_late.c
+++ b/tests/test_late.c
@@ -48,7 +48,7 @@ static int check_maxsim_batch_parity(const float *query,
}
for (int i = 0; i < n_docs; i++) {
float one = ffwd_late_maxsim(query, query_tokens, docs + (size_t)offsets[i] * dim,
- offsets[i + 1] - offsets[i], dim);
+ offsets[i + 1] - offsets[i], dim);
if (fabsf(scores[i] - one) > 0.0001f) {
fprintf(stderr, "maxsim_batch (%s) doc %d: %g vs %g\n", what, i, scores[i], one);
return 1;
@@ -257,7 +257,7 @@ int main(void) {
}
for (int i = 0; i < 3; i++) {
if (ffwd_late_model_encode_tokens(late, ws, doc_ids[i], lens[i], 1,
- doc_vecs + (size_t)offsets[i] * TOKEN_DIM) != 0) {
+ doc_vecs + (size_t)offsets[i] * TOKEN_DIM) != 0) {
fprintf(stderr, "doc encode failed\n");
goto fail;
}
@@ -269,10 +269,8 @@ int main(void) {
float scores[3];
int bad_first[4] = {1, 2, 3, 4};
int empty_doc[3] = {0, 2, 2};
- if (ffwd_late_maxsim_batch(vecs, n_tokens, doc_vecs, bad_first, 3, TOKEN_DIM, scores) ==
- 0 ||
- ffwd_late_maxsim_batch(vecs, n_tokens, doc_vecs, empty_doc, 2, TOKEN_DIM, scores) ==
- 0 ||
+ if (ffwd_late_maxsim_batch(vecs, n_tokens, doc_vecs, bad_first, 3, TOKEN_DIM, scores) == 0 ||
+ ffwd_late_maxsim_batch(vecs, n_tokens, doc_vecs, empty_doc, 2, TOKEN_DIM, scores) == 0 ||
ffwd_late_maxsim_batch(vecs, n_tokens, doc_vecs, offsets, 3, TOKEN_DIM, NULL) == 0) {
fprintf(stderr, "maxsim_batch accepted invalid arguments\n");
goto fail;
@@ -297,8 +295,8 @@ int main(void) {
keep_arrs[i][t] = t;
}
if (ffwd_late_model_encode_docs(late, ws, (const int *const *)doc_ids, lens,
- (const int *const *)keep_arrs, lens, 3, 1, batched,
- batch_offsets) != 0) {
+ (const int *const *)keep_arrs, lens, 3, 1, batched,
+ batch_offsets) != 0) {
fprintf(stderr, "encode_docs failed\n");
goto fail;
}
@@ -333,7 +331,7 @@ int main(void) {
if (!filtered)
goto fail;
if (ffwd_late_model_encode_docs(late, ws, one_ids, one_len, one_keep, one_nkeep, 1, 1,
- filtered, one_off) != 0 ||
+ filtered, one_off) != 0 ||
one_off[1] != nk0 ||
max_abs_diff(filtered, doc_vecs + TOKEN_DIM, (size_t)nk0 * TOKEN_DIM) > 0.0001f) {
fprintf(stderr, "encode_docs keep-filter mismatch\n");
@@ -345,14 +343,14 @@ int main(void) {
/* Invalid arguments must be rejected. */
if (ffwd_late_model_encode_docs(NULL, ws, (const int *const *)doc_ids, lens,
- (const int *const *)keep_arrs, lens, 3, 1, batched,
- batch_offsets) == 0 ||
+ (const int *const *)keep_arrs, lens, 3, 1, batched,
+ batch_offsets) == 0 ||
ffwd_late_model_encode_docs(late, ws, (const int *const *)doc_ids, lens,
- (const int *const *)keep_arrs, lens, 0, 1, batched,
- batch_offsets) == 0 ||
+ (const int *const *)keep_arrs, lens, 0, 1, batched,
+ batch_offsets) == 0 ||
ffwd_late_model_encode_docs(late, ws, (const int *const *)doc_ids, lens,
- (const int *const *)keep_arrs, lens, 3, 1, NULL,
- batch_offsets) == 0) {
+ (const int *const *)keep_arrs, lens, 3, 1, NULL,
+ batch_offsets) == 0) {
fprintf(stderr, "encode_docs accepted invalid arguments\n");
goto fail;
}
diff --git a/tests/test_qwen3.c b/tests/test_qwen3.c
index 5d1387a..50f7e02 100644
--- a/tests/test_qwen3.c
+++ b/tests/test_qwen3.c
@@ -36,9 +36,8 @@ int main(void) {
fprintf(stderr, "model setup failed\n");
return 1;
}
- if (cfg->attention_mode != FFWD_ATTENTION_CAUSAL ||
- cfg->pooling_mode != FFWD_POOL_LAST_TOKEN || !cfg->normalize_embeddings ||
- !cfg->append_terminal_token) {
+ if (cfg->attention_mode != FFWD_ATTENTION_CAUSAL || cfg->pooling_mode != FFWD_POOL_LAST_TOKEN ||
+ !cfg->normalize_embeddings || !cfg->append_terminal_token) {
fprintf(stderr, "Qwen3 config semantics were not detected\n");
return 1;
}
diff --git a/tests/test_workspace.c b/tests/test_workspace.c
index 1921465..ca5b136 100644
--- a/tests/test_workspace.c
+++ b/tests/test_workspace.c
@@ -165,8 +165,8 @@ static int check_spans_batch_parity(const ffwd_model_t *model,
ffwd_span_t spans0[2] = {{0, ntok[0]}, {ntok[0] + 1, ntok[1]}};
ffwd_span_t span1 = {0, ntok[2]};
if (ffwd_model_encode_spans(model, ws, doc0, n0, spans0, 2, expected) != 0 ||
- ffwd_model_encode_spans(model, ws, ids[2], ntok[2], &span1, 1,
- expected + (size_t)2 * dim) != 0) {
+ ffwd_model_encode_spans(model, ws, ids[2], ntok[2], &span1, 1, expected + (size_t)2 * dim) !=
+ 0) {
fprintf(stderr, "singleton contextual embedding failed\n");
goto done;
}