Skip to content

Commit 3676778

Browse files
Cong Liuflynnjiang
authored andcommitted
ggml/kompute: Implement ggml_backend_i.offload_op interface
Signed-off-by: Cong Liu <liucong@kylinos.cn>
1 parent d94ad56 commit 3676778

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

ggml/src/ggml-kompute.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2002,6 +2002,14 @@ static bool ggml_backend_kompute_supports_buft(ggml_backend_t backend, ggml_back
20022002
return &ctx->buft == buft;
20032003
}
20042004

2005+
static bool ggml_backend_kompute_offload_op(ggml_backend_t backend, const ggml_tensor * op) {
2006+
GGML_UNUSED(backend);
2007+
const int min_batch_size = 32;
2008+
2009+
return (op->ne[1] >= min_batch_size && op->op != GGML_OP_GET_ROWS) ||
2010+
(op->ne[2] >= min_batch_size && op->op == GGML_OP_MUL_MAT_ID);
2011+
}
2012+
20052013
static struct ggml_backend_i kompute_backend_i = {
20062014
/* .get_name = */ ggml_backend_kompute_name,
20072015
/* .free = */ ggml_backend_kompute_free,
@@ -2017,7 +2025,7 @@ static struct ggml_backend_i kompute_backend_i = {
20172025
/* .graph_compute = */ ggml_backend_kompute_graph_compute,
20182026
/* .supports_op = */ ggml_backend_kompute_supports_op,
20192027
/* .supports_buft = */ ggml_backend_kompute_supports_buft,
2020-
/* .offload_op = */ NULL,
2028+
/* .offload_op = */ ggml_backend_kompute_offload_op,
20212029
/* .event_new = */ NULL,
20222030
/* .event_free = */ NULL,
20232031
/* .event_record = */ NULL,

0 commit comments

Comments
 (0)