mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2026-09-24 13:37:01 +02:00
ggml-meta: resolve multi buffer views (#29266)
* ggml-meta: resolve multi buffer views * add TODO to revisit if graph allocator gets refactored
This commit is contained in:
@@ -1200,11 +1200,6 @@ static enum ggml_status ggml_backend_meta_buffer_init_tensor_impl(ggml_backend_m
|
||||
ggml_context * simple_ctx = stc.ctxs[j].get();
|
||||
ggml_backend_buffer_t simple_buf = buf_ctx->bufs[j].get();
|
||||
|
||||
if ((simple_buf != nullptr) && ggml_backend_buffer_is_multi_buffer(simple_buf)) {
|
||||
// see https://github.com/ggml-org/llama.cpp/issues/22197
|
||||
GGML_ABORT("multi buffers are not supported by the meta backend");
|
||||
}
|
||||
|
||||
if (split_dim >= 0 && split_dim < GGML_MAX_DIMS) {
|
||||
// TODO: the following assert fails for llama-parallel even though the results are correct:
|
||||
// GGML_ASSERT(ggml_is_contiguously_allocated(tensor));
|
||||
@@ -1252,16 +1247,27 @@ static enum ggml_status ggml_backend_meta_buffer_init_tensor_impl(ggml_backend_m
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO: revisit once the graph allocator has been refactored, see https://github.com/ggml-org/llama.cpp/pull/25051#issuecomment-4842873396
|
||||
ggml_backend_buffer_t init_buf = simple_buf;
|
||||
if (t_ij->view_src != nullptr) {
|
||||
t_ij->data = (char *) t_ij->view_src->data + t_ij->view_offs;
|
||||
// views inherit the source slice's concrete sub-buffer (issue 22197)
|
||||
if (tensor->view_src != nullptr && ggml_backend_buffer_is_meta(tensor->view_src->buffer)
|
||||
&& t_ij->view_src->buffer != nullptr) {
|
||||
t_ij->buffer = t_ij->view_src->buffer;
|
||||
init_buf = t_ij->view_src->buffer;
|
||||
}
|
||||
} else if (simple_buf != nullptr) {
|
||||
if (ggml_backend_buffer_is_multi_buffer(simple_buf)) {
|
||||
GGML_ABORT("multi buffers are not supported by the meta backend");
|
||||
}
|
||||
t_ij->data = (char *) ggml_backend_buffer_get_base(simple_buf)
|
||||
+ size_t(tensor->data) - size_t(ggml_backend_buffer_get_base(tensor->buffer));
|
||||
}
|
||||
|
||||
if (simple_buf) {
|
||||
if (init_buf) {
|
||||
// the backend that owns the buffer will set .extra
|
||||
ggml_backend_buffer_init_tensor(simple_buf, t_ij);
|
||||
ggml_backend_buffer_init_tensor(init_buf, t_ij);
|
||||
} else {
|
||||
t_ij->extra = tensor->extra;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user