aboutsummaryrefslogtreecommitdiff
path: root/bench/bench_model.c
diff options
context:
space:
mode:
authorOnur Gündüz <ogunduz@gmail.com>2026-06-15 08:40:11 +0200
committerOnur Gündüz <ogunduz@gmail.com>2026-06-15 08:40:11 +0200
commitc4a1c97a09da6d8d88c2ac834bf6234506fc41bc (patch)
tree81ce5675ce886aad0309a41f4d6a696826e0a061 /bench/bench_model.c
parentb377ba8656bfb807ed8dda6c9f26942b50ce626d (diff)
downloadffwd-c4a1c97a09da6d8d88c2ac834bf6234506fc41bc.tar.gz
ffwd-c4a1c97a09da6d8d88c2ac834bf6234506fc41bc.zip
chore: run clang-format
Diffstat (limited to 'bench/bench_model.c')
-rw-r--r--bench/bench_model.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/bench/bench_model.c b/bench/bench_model.c
index 9b897e9..5cff015 100644
--- a/bench/bench_model.c
+++ b/bench/bench_model.c
@@ -19,15 +19,15 @@ static int g_hidden;
enum { MAX_BATCH = 8 };
-static void bm_embed(bench_state_t *b, int batch, int len)
-{
+static void bm_embed(bench_state_t *b, int batch, int len) {
int *ids = (int *)malloc((size_t)batch * len * sizeof(int));
float *out = (float *)malloc((size_t)batch * g_hidden * sizeof(float));
- if (!ids || !out) exit(2);
+ if (!ids || !out)
+ exit(2);
unsigned s = 99u;
for (int i = 0; i < batch * len; i++) {
s = s * 1664525u + 1013904223u;
- ids[i] = (int)(s % 1000u); /* ordinary vocab rows */
+ ids[i] = (int)(s % 1000u); /* ordinary vocab rows */
}
embed_input_t inputs[MAX_BATCH];
for (int i = 0; i < batch; i++) {
@@ -44,8 +44,8 @@ static void bm_embed(bench_state_t *b, int batch, int len)
free(ids);
}
-static void bm_embed_b1_len32(bench_state_t *b) { bm_embed(b, 1, 32); }
-static void bm_embed_b8_len32(bench_state_t *b) { bm_embed(b, 8, 32); }
+static void bm_embed_b1_len32(bench_state_t *b) { bm_embed(b, 1, 32); }
+static void bm_embed_b8_len32(bench_state_t *b) { bm_embed(b, 8, 32); }
static void bm_embed_b1_len256(bench_state_t *b) { bm_embed(b, 1, 256); }
static const bench_case_t CASES[] = {
@@ -54,11 +54,9 @@ static const bench_case_t CASES[] = {
{"embed/b1_len256", bm_embed_b1_len256},
};
-int main(int argc, char **argv)
-{
+int main(int argc, char **argv) {
if (argc < 2 || argv[1][0] == '-') {
- fprintf(stderr, "usage: %s MODEL_DIR [--threads N] [bench flags]\n",
- argv[0]);
+ fprintf(stderr, "usage: %s MODEL_DIR [--threads N] [bench flags]\n", argv[0]);
return 2;
}
@@ -67,7 +65,8 @@ int main(int argc, char **argv)
if (!strcmp(argv[i], "--threads") && i + 1 < argc)
threads = atoi(argv[i + 1]);
}
- if (threads < 1) threads = 1;
+ if (threads < 1)
+ threads = 1;
qwen_set_threads(threads);
g_model = embed_model_load(argv[1]);
@@ -83,8 +82,7 @@ int main(int argc, char **argv)
g_hidden = embed_model_config(g_model)->hidden_size;
char meta[160];
- snprintf(meta, sizeof(meta), "suite=model threads=%d hidden=%d",
- threads, g_hidden);
+ snprintf(meta, sizeof(meta), "suite=model threads=%d hidden=%d", threads, g_hidden);
bench_opts_t opts = {0};
opts.meta = meta;