Generic test/benchmark harness using ck_model_* API. More...
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <time.h>#include <sys/time.h>#include <fcntl.h>#include <unistd.h>#include <sys/mman.h>#include <sys/stat.h>#include "ck_model_api.h"Go to the source code of this file.
Functions | |
| static double | get_time_ms (void) |
| static int | load_weights_from_bump (void *model, const char *bump_path) |
| int | main (int argc, char **argv) |
| static void | print_usage (const char *prog) |
| static void | run_benchmark (void *model, int num_tokens) |
| static void | run_generation_test (void *model, int num_tokens) |
| static int | sample_argmax (const float *logits, int vocab_size) |
Generic test/benchmark harness using ck_model_* API.
This file works with ANY model - just link with different inference.c
Build: gcc test_generic_api.c inference.c kernels/*.c -o test_bench -lm -lpthread
Run: ./test_bench –weights weights.bump –benchmark 100
Definition in file v6.6/test_generic_api.c.
|
static |
|
static |
Definition at line 40 of file v6.6/test_generic_api.c.
References ck_model_get_base(), ck_model_get_config(), ck_model_get_total_bytes(), and CKModelConfig::weight_bytes.
Referenced by main().
| int main | ( | int | argc, |
| char ** | argv | ||
| ) |
Definition at line 195 of file v6.6/test_generic_api.c.
References ck_model_create(), ck_model_free(), ck_model_get_config(), ck_model_precompute_rope(), CKModelConfig::embed_dim, CKModelConfig::intermediate_size, load_weights_from_bump(), CKModelConfig::max_seq_len, CKModelConfig::model_family, CKModelConfig::model_name, CKModelConfig::num_heads, CKModelConfig::num_kv_heads, CKModelConfig::num_layers, print_usage(), run_benchmark(), run_generation_test(), CKModelConfig::total_bytes, CKModelConfig::vocab_size, and CKModelConfig::weight_bytes.
|
static |
|
static |
Definition at line 105 of file v6.6/test_generic_api.c.
References ck_model_decode(), ck_model_get_config(), ck_model_verify_canaries(), CKModelConfig::embed_dim, end, get_time_ms(), CKModelConfig::model_name, CKModelConfig::num_heads, CKModelConfig::num_kv_heads, CKModelConfig::num_layers, start, token, and CKModelConfig::vocab_size.
Referenced by main().
|
static |
Definition at line 161 of file v6.6/test_generic_api.c.
References ck_model_decode(), ck_model_get_config(), ck_model_get_logits(), sample_argmax(), token, and CKModelConfig::vocab_size.
Referenced by main().
|
static |
Definition at line 89 of file v6.6/test_generic_api.c.
References vocab_size.
Referenced by run_generation_test().