File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -1045,9 +1045,25 @@ struct GGMLRunner {
10451045 reset_compute_ctx ();
10461046 struct ggml_cgraph * gf = get_graph ();
10471047 backend_tensor_data_map.clear ();
1048- compute_allocr = ggml_gallocr_new (ggml_backend_get_default_buffer_type (backend));
1048+
1049+ ggml_backend_buffer_type_t bufts[2 ] = {
1050+ ggml_backend_get_default_buffer_type (backend),
1051+ ggml_backend_get_default_buffer_type (backend)
1052+ };
10491053
1050- if (!ggml_gallocr_reserve (compute_allocr, gf)) {
1054+ compute_allocr = ggml_gallocr_new_n_multi (bufts, 2 );
1055+
1056+ int n_nodes = ggml_graph_n_nodes (gf);
1057+
1058+ int total_n_half = n_nodes / 2 ;
1059+
1060+ int * node_buffer_ids = (int *)calloc (n_nodes, sizeof (int ));
1061+
1062+ for (int i = 0 ; i < n_nodes; i++) {
1063+ node_buffer_ids[i] = i < total_n_half ? 0 : 1 ;
1064+ }
1065+
1066+ if (!ggml_gallocr_reserve_n (compute_allocr, gf, node_buffer_ids, NULL )) {
10511067 // failed to allocate the compute buffer
10521068 LOG_ERROR (" %s: failed to allocate the compute buffer\n " , get_desc ().c_str ());
10531069 free_compute_buffer ();
You can’t perform that action at this time.
0 commit comments