MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / eval_perf

Method eval_perf

tests/test-backend-ops.cpp:1455–1583  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1453 }
1454
1455 bool eval_perf(ggml_backend_t backend, const char * op_names_filter, printer * output_printer) {
1456 mode = MODE_PERF;
1457
1458 static const size_t graph_nodes = 8192;
1459
1460 ggml_init_params params = {
1461 /* .mem_size = */ ggml_tensor_overhead()*128 + ggml_graph_overhead_custom(graph_nodes, false),
1462 /* .mem_base = */ NULL,
1463 /* .no_alloc = */ true,
1464 };
1465 ggml_context_ptr ctx(ggml_init(params)); // smart ptr
1466 GGML_ASSERT(ctx);
1467
1468 ggml_tensor * out = build_graph(ctx.get());
1469 current_op_name = op_desc(out);
1470 if (!matches_filter(out, op_names_filter)) {
1471 //printf(" %s: skipping\n", op_desc(out).c_str());
1472 return true;
1473 }
1474
1475 if (!ggml_backend_supports_op(backend, out)) {
1476 // Create test result for unsupported performance test
1477 test_result result(ggml_backend_name(backend), current_op_name, vars(), "perf", false, false,
1478 "not supported");
1479
1480 output_printer->print_test_result(result);
1481
1482 return true;
1483 }
1484
1485 // allocate
1486 ggml_backend_buffer_ptr buf(ggml_backend_alloc_ctx_tensors(ctx.get(), backend)); // smart ptr
1487
1488 if (buf == NULL) {
1489 printf("failed to allocate tensors\n");
1490 return false;
1491 }
1492
1493 // randomize tensors
1494 initialize_tensors(ctx.get());
1495
1496 // build graph
1497 ggml_cgraph * gf = ggml_new_graph_custom(ctx.get(), graph_nodes, false);
1498 ggml_build_forward_expand(gf, out);
1499
1500 // warmup run
1501 ggml_status status = ggml_backend_graph_compute(backend, gf);
1502 if (status != GGML_STATUS_SUCCESS) {
1503 fprintf(stderr, "%s: ggml_backend_graph_compute failed. status=%s \n", __func__, ggml_status_to_string(status));
1504 return false;
1505 }
1506
1507 // determine number of runs
1508 int n_runs;
1509 bool is_cpu = ggml_backend_dev_type(ggml_backend_get_device(backend)) == GGML_BACKEND_DEVICE_TYPE_CPU;
1510 if (op_flops(out) > 0) {
1511 // based on flops
1512 const uint64_t GFLOP = 1000 * 1000 * 1000;

Callers 1

test_backendFunction · 0.80

Calls 15

ggml_tensor_overheadFunction · 0.85
ggml_initFunction · 0.85
op_descClass · 0.85
ggml_backend_supports_opFunction · 0.85
ggml_backend_nameFunction · 0.85
ggml_new_graph_customFunction · 0.85
ggml_status_to_stringFunction · 0.85
ggml_backend_get_deviceFunction · 0.85

Tested by

no test coverage detected