Skip to content

Commit 7095422

Browse files
metal: align with CUDA, inkling2 decode 1.5x faster
1 parent 960497e commit 7095422

17 files changed

Lines changed: 522 additions & 140 deletions

‎ggml/src/ggml-metal/ggml-metal-common.cpp‎

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,18 @@ static bool ggml_mem_ranges_add(ggml_mem_ranges_t mrs, ggml_mem_range mr) {
200200
}
201201

202202
static ggml_mem_range ggml_mem_range_from_tensor(const ggml_tensor * tensor, ggml_mem_range_type pt) {
203-
// always use the base tensor
203+
// an allocated view covers its own bytes only: disjoint views of one tensor (e.g. the slots of a recurrent
204+
// state) do not conflict
205+
if (tensor->view_src && tensor->buffer && tensor->data && !ggml_is_empty(tensor)) {
206+
return {
207+
/*.pb =*/ (uint64_t) tensor->buffer,
208+
/*.p0 =*/ (uint64_t) tensor->data,
209+
/*.p1 =*/ (uint64_t) tensor->data + ggml_nbytes(tensor),
210+
/*.pt =*/ pt,
211+
};
212+
}
213+
214+
// otherwise use the base tensor
204215
tensor = tensor->view_src ? tensor->view_src : tensor;
205216

206217
GGML_ASSERT(!tensor->view_src);
@@ -241,7 +252,7 @@ static ggml_mem_range ggml_mem_range_from_tensor_dst(const ggml_tensor * tensor)
241252
return ggml_mem_range_from_tensor(tensor, MEM_RANGE_TYPE_DST);
242253
}
243254

244-
static bool ggml_mem_ranges_add_src(ggml_mem_ranges_t mrs, const ggml_tensor * tensor) {
255+
bool ggml_mem_ranges_add_src(ggml_mem_ranges_t mrs, const ggml_tensor * tensor) {
245256
GGML_ASSERT(tensor);
246257

247258
ggml_mem_range mr = ggml_mem_range_from_tensor_src(tensor);
@@ -253,7 +264,7 @@ static bool ggml_mem_ranges_add_src(ggml_mem_ranges_t mrs, const ggml_tensor * t
253264
return ggml_mem_ranges_add(mrs, mr);
254265
}
255266

256-
static bool ggml_mem_ranges_add_dst(ggml_mem_ranges_t mrs, const ggml_tensor * tensor) {
267+
bool ggml_mem_ranges_add_dst(ggml_mem_ranges_t mrs, const ggml_tensor * tensor) {
257268
GGML_ASSERT(tensor);
258269

259270
ggml_mem_range mr = ggml_mem_range_from_tensor_dst(tensor);
@@ -289,7 +300,8 @@ static bool ggml_mem_ranges_check(ggml_mem_ranges_t mrs, ggml_mem_range mr) {
289300
continue;
290301
}
291302

292-
if (mr.p0 < cmp.p1 && mr.p1 >= cmp.p0) {
303+
// half-open ranges: adjacent ones do not intersect
304+
if (mr.p0 < cmp.p1 && mr.p1 > cmp.p0) {
293305
if (mrs->debug > 2) {
294306
GGML_LOG_DEBUG("%s: the %s range buf=%lld, [%lld, %lld) overlaps with a previous %s range buf=%lld, [%lld, %lld)\n",
295307
__func__,
@@ -306,7 +318,7 @@ static bool ggml_mem_ranges_check(ggml_mem_ranges_t mrs, ggml_mem_range mr) {
306318
return true;
307319
}
308320

309-
static bool ggml_mem_ranges_check_src(ggml_mem_ranges_t mrs, const ggml_tensor * tensor) {
321+
bool ggml_mem_ranges_check_src(ggml_mem_ranges_t mrs, const ggml_tensor * tensor) {
310322
GGML_ASSERT(tensor);
311323

312324
ggml_mem_range mr = ggml_mem_range_from_tensor_src(tensor);
@@ -316,7 +328,7 @@ static bool ggml_mem_ranges_check_src(ggml_mem_ranges_t mrs, const ggml_tensor *
316328
return res;
317329
}
318330

319-
static bool ggml_mem_ranges_check_dst(ggml_mem_ranges_t mrs, const ggml_tensor * tensor) {
331+
bool ggml_mem_ranges_check_dst(ggml_mem_ranges_t mrs, const ggml_tensor * tensor) {
320332
GGML_ASSERT(tensor);
321333

322334
ggml_mem_range mr = ggml_mem_range_from_tensor_dst(tensor);
@@ -375,6 +387,12 @@ struct node_info {
375387
static std::vector<int> ggml_metal_graph_optimize_reorder(const std::vector<node_info> & nodes) {
376388
// helper to add node src and dst ranges
377389
const auto & h_add = [](ggml_mem_ranges_t mrs, const node_info & node) {
390+
// a view neither reads nor writes: its range would be the one of the viewed tensor, as a destination,
391+
// which would serialize the later readers of that tensor
392+
if (node.is_empty() && node.fused.empty()) {
393+
return true;
394+
}
395+
378396
// only external sources matter: sources produced by the fused group are internal
379397
for (int i = 0; i < GGML_MAX_SRC; i++) {
380398
const ggml_tensor * src = node.node->src[i];
@@ -473,6 +491,9 @@ static std::vector<int> ggml_metal_graph_optimize_reorder(const std::vector<node
473491
case GGML_OP_CPY:
474492
case GGML_OP_CONT:
475493
case GGML_OP_REPEAT:
494+
case GGML_OP_CONCAT:
495+
case GGML_OP_PAD:
496+
case GGML_OP_SOFT_MAX:
476497
return true;
477498
default:
478499
return ggml_op_is_empty(op);

‎ggml/src/ggml-metal/ggml-metal-common.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ bool ggml_mem_ranges_add(ggml_mem_ranges_t mrs, const struct ggml_tensor * tenso
4444
// - new dst range overlaps with any existing range (src or dst)
4545
bool ggml_mem_ranges_check(ggml_mem_ranges_t mrs, const struct ggml_tensor * tensor);
4646

47+
// the read or the write of one tensor only
48+
bool ggml_mem_ranges_add_src (ggml_mem_ranges_t mrs, const struct ggml_tensor * tensor);
49+
bool ggml_mem_ranges_add_dst (ggml_mem_ranges_t mrs, const struct ggml_tensor * tensor);
50+
bool ggml_mem_ranges_check_src(ggml_mem_ranges_t mrs, const struct ggml_tensor * tensor);
51+
bool ggml_mem_ranges_check_dst(ggml_mem_ranges_t mrs, const struct ggml_tensor * tensor);
52+
4753
// reorder the nodes in the graph to improve concurrency, while respecting the fusions of a device with props
4854
//
4955
// note: this implementation is generic and not specific to metal

‎ggml/src/ggml-metal/ggml-metal-context.m‎

Lines changed: 54 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
// max number of MTLCommandBuffer used to submit a graph for processing
2121
#define GGML_METAL_MAX_COMMAND_BUFFERS 8
2222

23+
// the fewest extra command buffers: short ones keep the GPU fed while the rest of the graph is encoded
24+
#define GGML_METAL_N_CB_STREAM 8
25+
2326
struct ggml_metal_command_buffer {
2427
id<MTLCommandBuffer> obj;
2528
};
@@ -52,7 +55,8 @@
5255
id<MTLCaptureScope> capture_scope;
5356

5457
// command buffer state
55-
int n_cb; // number of extra threads used to submit the command buffers
58+
int n_cb; // number of extra command buffers
59+
int n_par; // number of extra threads used to submit them
5660

5761
// first node of each extra command buffer, then the end of the graph
5862
int cb_start[GGML_METAL_MAX_COMMAND_BUFFERS + 1];
@@ -155,7 +159,8 @@ ggml_metal_t ggml_metal_init(ggml_metal_device_t dev) {
155159
res->finfo = ggml_metal_device_get_fusion_info(dev);
156160
if (ggml_metal_fusion_info_stats(res->finfo)) {
157161
ggml_metal_fusion_info_labels_init(res->finfo);
158-
res->n_cb = 0;
162+
res->n_cb = 0;
163+
res->n_par = 0;
159164
}
160165

161166
GGML_LOG_INFO("%s: use fusion = %s\n", __func__, ggml_metal_fusion_info_enabled(res->finfo) ? "true" : "false");
@@ -482,10 +487,13 @@ enum ggml_status ggml_metal_graph_compute(ggml_metal_t ctx, struct ggml_cgraph *
482487
}
483488

484489
// number of nodes encoded by the main thread (empirically determined)
485-
const int n_main = MAX(64, 0.1*gf->n_nodes);
490+
// number of command buffers in addition to the main one, and of threads that encode them
491+
const int n_cb = ctx->n_cb;
492+
const int n_par = ctx->n_par;
486493

487-
// number of threads in addition to the main thread
488-
const int n_cb = ctx->n_cb;
494+
// when a thread encodes several command buffers in order, each one is committed as soon as it is encoded and the
495+
// GPU starts early on a short first one; otherwise the main thread covers the time the threads need
496+
const int n_main = n_par < n_cb ? MAX(64, gf->n_nodes/25) : MAX(64, 0.1*gf->n_nodes);
489497

490498
// keep the memory wired
491499
ggml_metal_device_rsets_keep_alive(ctx->dev);
@@ -503,18 +511,14 @@ enum ggml_status ggml_metal_graph_compute(ggml_metal_t ctx, struct ggml_cgraph *
503511
// the main thread encodes [0, cb_start[0]) and the extra command buffer i encodes [cb_start[i], cb_start[i + 1])
504512
// a fusion cannot span two command buffers, so each boundary moves to the end of the fusable group it falls
505513
// into and the encoders fuse the same nodes as with a single command buffer
514+
// only the boundary of the main command buffer is needed before its encoding: the others are found while the
515+
// GPU runs it
516+
int i_split = 0;
506517
{
507-
const int n_rest = gf->n_nodes - MIN(n_main, gf->n_nodes);
508-
const int n_per_cb = n_cb > 0 ? (n_rest + n_cb - 1) / n_cb : 0;
509-
510-
int i = 0;
511-
for (int cb_idx = 0; cb_idx < n_cb; ++cb_idx) {
512-
const int target = MIN(n_main + cb_idx*n_per_cb, gf->n_nodes);
513-
while (i < target) {
514-
i += ggml_metal_fusion_max(gf, i);
515-
}
516-
ctx->cb_start[cb_idx] = MIN(i, gf->n_nodes);
518+
while (i_split < MIN(n_main, gf->n_nodes)) {
519+
i_split += ggml_metal_fusion_max(gf, i_split);
517520
}
521+
ctx->cb_start[0] = n_cb > 0 ? MIN(i_split, gf->n_nodes) : gf->n_nodes;
518522
ctx->cb_start[n_cb] = gf->n_nodes;
519523
}
520524

@@ -582,6 +586,20 @@ enum ggml_status ggml_metal_graph_compute(ggml_metal_t ctx, struct ggml_cgraph *
582586
// remember the command buffer for the next iteration
583587
ctx->cmd_buf_last = ctx->cmd_bufs[n_cb].obj;
584588

589+
if (n_cb > 0) {
590+
const int n_rest = gf->n_nodes - ctx->cb_start[0];
591+
const int n_per_cb = (n_rest + n_cb - 1) / n_cb;
592+
593+
int i = ctx->cb_start[0];
594+
for (int cb_idx = 1; cb_idx < n_cb; ++cb_idx) {
595+
const int target = MIN(ctx->cb_start[0] + cb_idx*n_per_cb, gf->n_nodes);
596+
while (i < target) {
597+
i += ggml_metal_fusion_max(gf, i);
598+
}
599+
ctx->cb_start[cb_idx] = MIN(i, gf->n_nodes);
600+
}
601+
}
602+
585603
// prepare the rest of the command buffers asynchronously (optional)
586604
// cmd_buf[0.. n_cb)
587605
for (int cb_idx = 0; cb_idx < n_cb; ++cb_idx) {
@@ -604,7 +622,18 @@ enum ggml_status ggml_metal_graph_compute(ggml_metal_t ctx, struct ggml_cgraph *
604622
}
605623
}
606624

607-
dispatch_apply(n_cb, ctx->d_queue, ctx->encode_async);
625+
if (n_par == n_cb) {
626+
dispatch_apply(n_cb, ctx->d_queue, ctx->encode_async);
627+
} else if (n_par > 0) {
628+
// each thread encodes a run of consecutive command buffers, in order
629+
void (^enc)(size_t) = ctx->encode_async;
630+
dispatch_apply(n_par, ctx->d_queue, ^(size_t t) {
631+
const int per = (n_cb + n_par - 1)/n_par;
632+
for (int cb_idx = t*per; cb_idx < MIN((int) (t + 1)*per, n_cb); ++cb_idx) {
633+
enc(cb_idx);
634+
}
635+
});
636+
}
608637

609638
// for debugging: block until graph is computed
610639
//[ctx->cmd_buf_last waitUntilCompleted];
@@ -676,6 +705,7 @@ enum ggml_status ggml_metal_graph_compute(ggml_metal_t ctx, struct ggml_cgraph *
676705
return res;
677706
}
678707
}
708+
679709
}
680710

681711
return GGML_STATUS_SUCCESS;
@@ -734,10 +764,15 @@ void ggml_metal_set_n_cb(ggml_metal_t ctx, int n_cb) {
734764
n_cb = 0;
735765
}
736766

737-
if (ctx->n_cb != n_cb) {
738-
ctx->n_cb = MIN(n_cb, GGML_METAL_MAX_COMMAND_BUFFERS);
767+
// n_cb threads encode at least GGML_METAL_N_CB_STREAM command buffers, the ones of a thread in order
768+
const int n_par = MIN(MAX(n_cb, 0), GGML_METAL_MAX_COMMAND_BUFFERS);
769+
const int n_buf = n_par > 0 ? MIN(MAX(n_par, GGML_METAL_N_CB_STREAM), GGML_METAL_MAX_COMMAND_BUFFERS) : 0;
770+
771+
if (ctx->n_par != n_par || ctx->n_cb != n_buf) {
772+
ctx->n_par = n_par;
773+
ctx->n_cb = n_buf;
739774

740-
if (ctx->n_cb > 2) {
775+
if (n_par > 2) {
741776
GGML_LOG_WARN("%s: n_cb = %d, using n_cb > 2 is not recommended and can degrade the performance in some cases\n", __func__, n_cb);
742777
}
743778
}

‎ggml/src/ggml-metal/ggml-metal-device.cpp‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2532,6 +2532,15 @@ ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_snake(ggml_metal
25322532
return res;
25332533
}
25342534

2535+
ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_by_name(ggml_metal_library_t lib, const char * name) {
2536+
ggml_metal_pipeline_with_params res = ggml_metal_library_get_pipeline(lib, name);
2537+
if (!res.pipeline) {
2538+
res = ggml_metal_library_compile_pipeline(lib, name, name, nullptr);
2539+
}
2540+
2541+
return res;
2542+
}
2543+
25352544
ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_conv_transpose_2d(ggml_metal_library_t lib, const ggml_tensor * op) {
25362545
assert(op->op == GGML_OP_CONV_TRANSPOSE_2D);
25372546

‎ggml/src/ggml-metal/ggml-metal-device.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_conv_tran
168168
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_conv_transpose_2d (ggml_metal_library_t lib, const struct ggml_tensor * op);
169169
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_col2im_1d (ggml_metal_library_t lib, const struct ggml_tensor * op);
170170
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_snake (ggml_metal_library_t lib, enum ggml_type type);
171+
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_by_name (ggml_metal_library_t lib, const char * name);
171172
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_conv_2d (ggml_metal_library_t lib, const struct ggml_tensor * op);
172173
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_conv_2d_mm (ggml_metal_library_t lib, const struct ggml_tensor * op);
173174
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_conv_2d_mm_reduce (ggml_metal_library_t lib, const struct ggml_tensor * op);

‎ggml/src/ggml-metal/ggml-metal-fusion.cpp‎

Lines changed: 45 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,34 @@ static bool ggml_metal_fusion_check_snake(
341341
return types_ok && shape_ok && dim_ok && contig_ok && x_in_add == x;
342342
}
343343

344+
345+
// x*tab[ids], one factor per expert: GET_ROWS of the factors [1, n_expert(, n_tokens)] by the ids [n_used, n_tokens]
346+
static bool ggml_metal_fusion_check_scale_id(
347+
const ggml_metal_fusion * fusion,
348+
const ggml_tensor * const * n,
349+
const ggml_cgraph * gf,
350+
const int * node_idxs,
351+
int idx,
352+
ggml_metal_fusion_mode mode) {
353+
GGML_UNUSED(fusion);
354+
GGML_UNUSED(mode);
355+
356+
const ggml_tensor * rows = n[0];
357+
const ggml_tensor * mul = n[1];
358+
const ggml_tensor * tab = rows->src[0];
359+
const ggml_tensor * ids = rows->src[1];
360+
const ggml_tensor * x = mul->src[0] == rows ? mul->src[1] : mul->src[0];
361+
362+
if ((mul->src[0] != rows && mul->src[1] != rows) || !x || x->type != GGML_TYPE_F32 || !ggml_is_contiguous(x) ||
363+
!ggml_are_same_shape(x, mul) || mul->type != GGML_TYPE_F32 || !ggml_is_contiguous(mul) || x->ne[3] != 1 ||
364+
tab->type != GGML_TYPE_F32 || tab->ne[0] != 1 || tab->ne[3] != 1 || (tab->ne[2] != 1 && tab->ne[2] != x->ne[2]) ||
365+
ids->type != GGML_TYPE_I32 || ids->ne[0] != x->ne[1] || ids->ne[1] != x->ne[2] ||
366+
rows->ne[0] != 1 || rows->ne[1] != x->ne[1] || rows->ne[2] != x->ne[2]) {
367+
return false;
368+
}
369+
370+
return !(rows->flags & GGML_TENSOR_FLAG_OUTPUT) && ggml_node_get_use_count(gf, node_idxs[idx]) == 1;
371+
}
344372
#define GGML_METAL_TOPK_MOE_MAX_EXPERTS 1024
345373

346374
static const std::vector<ggml_op> ops_topk_moe = {
@@ -862,6 +890,8 @@ static const std::vector<ggml_op> ops_moe_reduce_8 = {
862890

863891
static const std::vector<ggml_op> ops_mul_mat_add = { GGML_OP_MUL_MAT, GGML_OP_ADD };
864892

893+
894+
static const std::vector<ggml_op> ops_scale_id = { GGML_OP_GET_ROWS, GGML_OP_MUL };
865895
static const std::vector<ggml_metal_fusion> ggml_metal_fusions = {
866896
{ GGML_METAL_FUSION_NORM_MUL, ops_norm_mul, {}, false, ggml_metal_fusion_check_norm },
867897
{ GGML_METAL_FUSION_NORM_MUL_ADD, ops_norm_mul_add, {}, false, ggml_metal_fusion_check_norm },
@@ -911,6 +941,8 @@ static const std::vector<ggml_metal_fusion> ggml_metal_fusions = {
911941
{ GGML_METAL_FUSION_SSM_CONV_SILU, ops_ssm_conv_silu, {}, false, ggml_metal_fusion_check_ssm_conv_silu },
912942

913943
{ GGML_METAL_FUSION_MUL_MAT_ADD, ops_mul_mat_add, {}, false, ggml_metal_fusion_check_mul_mat_add },
944+
945+
{ GGML_METAL_FUSION_SCALE_ID, ops_scale_id, {}, true, ggml_metal_fusion_check_scale_id },
914946
};
915947

916948
// ---- alloc deps -----------------------------------------------------------
@@ -1289,10 +1321,10 @@ const ggml_metal_fusion * ggml_metal_fusion_next(
12891321
return res;
12901322
}
12911323

1292-
// optimize phase: maximum number of nodes starting at idx (a raw sequential graph index) that
1293-
// could be fused, chaining patterns back-to-back. matching runs on the same filtered (view
1294-
// transparent) node sequence that the compute phase uses, so the returned count is the raw index
1295-
// span from idx to the last matched node (intermediate views are packed along).
1324+
// optimize phase: number of nodes starting at idx (a raw sequential graph index) that the longest
1325+
// pattern matching there fuses. matching runs on the same filtered (view transparent) node
1326+
// sequence that the compute phase uses, so the returned count is the raw index span from idx to
1327+
// the last matched node (intermediate views are packed along).
12961328
int ggml_metal_fusion_max(const ggml_cgraph * gf, int idx) {
12971329
// a view node cannot start a pattern - pack it alone
12981330
if (ggml_op_is_empty(gf->nodes[idx]->op)) {
@@ -1312,24 +1344,16 @@ int ggml_metal_fusion_max(const ggml_cgraph * gf, int idx) {
13121344
return 1;
13131345
}
13141346

1315-
int total = 0;
1316-
int i_f = 0;
1317-
1318-
while (i_f < n_idxs && total < GGML_METAL_FUSION_MAX) {
1319-
int len = 1;
1320-
const ggml_metal_fusion * fusion = ggml_metal_fusion_next(gf, idxs, n_idxs, i_f, GGML_METAL_FUSION_STRUCTURAL, &len);
1321-
if (!fusion || total + len > GGML_METAL_FUSION_MAX) {
1322-
break;
1323-
}
1324-
1325-
total += len;
1326-
i_f += len;
1327-
}
1328-
1329-
if (i_f == 0) {
1347+
// one pattern per group: back-to-back groups stay separate nodes for the reorder, which can then run
1348+
// independent chains side by side
1349+
int len = 1;
1350+
const ggml_metal_fusion * fusion = ggml_metal_fusion_next(gf, idxs, n_idxs, 0, GGML_METAL_FUSION_STRUCTURAL, &len);
1351+
if (!fusion) {
13301352
return 1;
13311353
}
13321354

1333-
// map the matched non-empty nodes back to the raw index span (views are included)
1334-
return std::min(GGML_METAL_FUSION_MAX, idxs[i_f - 1] - idx + 1);
1355+
const int i_f = len;
1356+
1357+
// map the matched non-empty nodes back to the raw index span (views are included, so it can exceed the op count)
1358+
return idxs[i_f - 1] - idx + 1;
13351359
}

‎ggml/src/ggml-metal/ggml-metal-fusion.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ typedef enum ggml_metal_fusion_id {
4343
GGML_METAL_FUSION_MOE_REDUCE, // MUL + expert VIEWs + ADD chain (MoE output reduction)
4444
GGML_METAL_FUSION_SSM_CONV_SILU, // SSM_CONV + UNARY (silu)
4545
GGML_METAL_FUSION_MUL_MAT_ADD, // MUL_MAT + ADD (residual added in the few-row MMA store)
46+
GGML_METAL_FUSION_SCALE_ID, // GET_ROWS + MUL: x scaled by a per-expert factor gathered by the expert ids
4647
} ggml_metal_fusion_id;
4748

4849
struct ggml_metal_fusion; // defined in ggml-metal-fusion.cpp
@@ -93,8 +94,8 @@ const ggml_metal_fusion * ggml_metal_fusion_next(
9394
ggml_metal_fusion_mode mode,
9495
int * n_out);
9596

96-
// optimize phase: maximum number of nodes starting at idx (a raw sequential graph index) that
97-
// could be fused on a device with props, chaining patterns back-to-back. returns at least 1.
97+
// optimize phase: number of nodes starting at idx (a raw sequential graph index) that the longest
98+
// pattern there fuses, views included. returns at least 1.
9899
int ggml_metal_fusion_max(const struct ggml_cgraph * gf, int idx);
99100

100101
#ifdef __cplusplus

0 commit comments

Comments
 (0)