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

Function sum_gpu_index

llama.cpp:2757–2779  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2755
2756
2757static int64_t sum_gpu_index(struct ggml_tensor * gpu_index) {
2758 ggml_context * ctx_aux = ggml_init({
2759 /* mem_size */ 1 << 10,
2760 });
2761
2762 GGML_ASSERT(ctx_aux);
2763
2764 ggml_cgraph * gf = ggml_new_graph_custom(ctx_aux, 1, false);
2765 ggml_tensor * sum = ggml_sum(ctx_aux, gpu_index);
2766
2767 ggml_set_name(sum, "gpu_index_sum");
2768 ggml_build_forward_expand(gf, sum);
2769
2770 // TODO: +1 worker for GPU under hybrid inference but no use
2771 // ggml_graph_compute_helper(work_buffer, gf, 2);
2772 ggml_graph_compute_with_ctx(ctx_aux, gf, 2);
2773
2774 int32_t sum_val = ggml_get_i32_1d(sum, 0);
2775
2776 ggml_free(ctx_aux);
2777
2778 return sum_val;
2779}
2780
2781struct llama_gpu_split_loader {
2782 int n_tensors = 0;

Callers 1

Calls 8

ggml_initFunction · 0.70
ggml_new_graph_customFunction · 0.70
ggml_sumFunction · 0.70
ggml_set_nameFunction · 0.70
ggml_get_i32_1dFunction · 0.70
ggml_freeFunction · 0.70

Tested by

no test coverage detected