MCPcopy Create free account
hub / github.com/antirez/ds4 / parse_options

Function parse_options

ds4_eval.c:1502–1689  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1500static ds4_backend default_backend(void) {
1501#ifdef DS4_NO_GPU
1502 return DS4_BACKEND_CPU;
1503#elif defined(__APPLE__)
1504 return DS4_BACKEND_METAL;
1505#else
1506 return DS4_BACKEND_CUDA;
1507#endif
1508}
1509
1510static void usage(FILE *fp, const char *topic) {
1511 ds4_help_print(fp, DS4_HELP_EVAL, topic);
1512}
1513
1514static eval_config parse_options(int argc, char **argv) {
1515 eval_config c = {
1516 .model_path = "ds4flash.gguf",
1517 .backend = default_backend(),
1518 .max_tokens = 16000,
1519 .top_p = DS4_DEFAULT_TOP_P,
1520 .min_p = DS4_DEFAULT_MIN_P,
1521 .pause_ms = 350,
1522 .soft_limit_reply_budget = 1024,
1523 .hard_limit_reply_budget = 512,
1524 .soft_limit_think_close_rank = 3,
1525 .think_mode = DS4_THINK_HIGH,
1526 };
1527
1528 for (int i = 1; i < argc; i++) {
1529 const char *arg = argv[i];
1530 if (!strcmp(arg, "-h") || !strcmp(arg, "--help")) {
1531 const char *topic = (i + 1 < argc && argv[i + 1][0] != '-') ?
1532 argv[i + 1] : NULL;
1533 usage(stdout, topic);
1534 exit(0);
1535 }
1536 char dist_parse_err[256] = {0};
1537 ds4_dist_cli_parse_result dist_parse =
1538 ds4_dist_parse_cli_arg(arg,
1539 &i,
1540 argc,
1541 argv,
1542 &c.dist,
1543 dist_parse_err,
1544 sizeof(dist_parse_err));
1545 if (dist_parse == DS4_DIST_CLI_ERROR) {
1546 fprintf(stderr,
1547 "ds4-eval: %s\n",
1548 dist_parse_err[0] ? dist_parse_err : "invalid distributed option");
1549 exit(2);
1550 }
1551 if (dist_parse == DS4_DIST_CLI_MATCHED) continue;
1552
1553 if (!strcmp(arg, "-m") || !strcmp(arg, "--model")) {
1554 c.model_path = need_arg(&i, argc, argv, arg);
1555 } else if (!strcmp(arg, "--mtp")) {
1556 c.mtp_path = need_arg(&i, argc, argv, arg);
1557 } else if (!strcmp(arg, "-c") || !strcmp(arg, "--ctx")) {
1558 c.ctx_size = parse_int_arg(need_arg(&i, argc, argv, arg), arg);
1559 } else if (!strcmp(arg, "-n") || !strcmp(arg, "--tokens")) {

Callers 1

mainFunction · 0.70

Calls 12

ds4_dist_parse_cli_argFunction · 0.85
parse_u64_argFunction · 0.85
ds4_parse_gib_argFunction · 0.85
ds4_think_mode_enabledFunction · 0.85
default_backendFunction · 0.70
usageFunction · 0.70
need_argFunction · 0.70
parse_int_argFunction · 0.70
parse_float_argFunction · 0.70
parse_backendFunction · 0.70

Tested by

no test coverage detected