MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / ggml_graph_compute

Function ggml_graph_compute

ggml.c:17380–17481  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17378}
17379
17380int ggml_graph_compute(struct ggml_cgraph * cgraph, struct ggml_cplan * cplan) {
17381 {
17382 GGML_ASSERT(cplan);
17383 GGML_ASSERT(cplan->n_threads > 0);
17384
17385 if (cplan->work_size > 0) {
17386 GGML_ASSERT(cplan->work_data);
17387 }
17388 }
17389
17390 const int n_threads = cplan->n_threads;
17391#ifdef GGML_USE_HYBRID_THREADING
17392 struct ggml_compute_state_shared state_shared = {
17393 /*.cgraph =*/ cgraph,
17394 /*.cgraph_plan =*/ cplan,
17395 /*.perf_node_start_cycles =*/ 0,
17396 /*.perf_node_start_time_us =*/ 0,
17397 /*.n_threads =*/ n_threads-1,
17398 /*.aic =*/ 0,
17399 /*.n_active =*/ n_threads-1,
17400 /*.node_n =*/ -1,
17401 /*.abort_callback =*/ NULL,
17402 /*.abort_callback_data =*/ NULL,
17403 };
17404#else
17405 struct ggml_compute_state_shared state_shared = {
17406 /*.cgraph =*/ cgraph,
17407 /*.cgraph_plan =*/ cplan,
17408 /*.perf_node_start_cycles =*/ 0,
17409 /*.perf_node_start_time_us =*/ 0,
17410 /*.n_threads =*/ n_threads,
17411 /*.aic =*/ 0,
17412 /*.n_active =*/ n_threads,
17413 /*.node_n =*/ -1,
17414 /*.abort_callback =*/ NULL,
17415 /*.abort_callback_data =*/ NULL,
17416 };
17417#endif
17418 struct ggml_compute_state * workers = alloca(sizeof(struct ggml_compute_state)*n_threads);
17419
17420 // create thread pool
17421 if (n_threads > 1) {
17422 for (int j = 1; j < n_threads; ++j) {
17423 workers[j] = (struct ggml_compute_state) {
17424 .thrd = 0,
17425 .ith = j,
17426 .shared = &state_shared,
17427 };
17428#ifdef GGML_USE_HYBRID_THREADING
17429 const int rc = ggml_thread_create(&workers[j].thrd, NULL, ggml_graph_compute_thread_hybrid, &workers[j]);
17430#else
17431 const int rc = ggml_thread_create(&workers[j].thrd, NULL, ggml_graph_compute_thread, &workers[j]);
17432#endif
17433 GGML_ASSERT(rc == 0);
17434 UNUSED(rc);
17435 }
17436 }
17437

Callers 12

ggml_opt_adamFunction · 0.70
linesearch_backtrackingFunction · 0.70
ggml_opt_lbfgsFunction · 0.70
apply_loraFunction · 0.50
clip_image_batch_encodeFunction · 0.50

Calls 4

ggml_cycles_per_msFunction · 0.70

Tested by 1