From e2389eb99cf5796659495c0066bb491fb52a354f Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Fri, 4 Sep 2026 13:08:43 +0300 Subject: [PATCH] ggml : rename and make private ggml_op_alloc_size_may_expand() (ggml/0) cont https://github.com/ggml-org/llama.cpp/pull/27960 --- ggml/include/ggml-backend.h | 4 ---- ggml/src/ggml-backend-impl.h | 5 +++++ ggml/src/ggml-backend.cpp | 7 ++----- ggml/src/ggml-rpc/ggml-rpc.cpp | 2 +- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/ggml/include/ggml-backend.h b/ggml/include/ggml-backend.h index 27375bd0a..cc3f8cd36 100644 --- a/ggml/include/ggml-backend.h +++ b/ggml/include/ggml-backend.h @@ -424,10 +424,6 @@ extern "C" { // Compare the output of two backends GGML_API bool ggml_backend_compare_graph_backend(ggml_backend_t backend1, ggml_backend_t backend2, struct ggml_cgraph * graph, ggml_backend_eval_callback callback, void * user_data, struct ggml_tensor const * const * test_nodes, size_t num_test_nodes); - // returns true for ops that may require additional memory for fleeting data on some backends, - // i.e. the backend's get_alloc_size may return more than ggml_nbytes for the output tensor - GGML_API bool ggml_backend_op_alloc_size_may_expand(enum ggml_op op); - // Tensor initialization GGML_API enum ggml_status ggml_backend_tensor_alloc(ggml_backend_buffer_t buffer, struct ggml_tensor * tensor, void * addr); GGML_API enum ggml_status ggml_backend_view_init(struct ggml_tensor * tensor); diff --git a/ggml/src/ggml-backend-impl.h b/ggml/src/ggml-backend-impl.h index 56f0090cc..ef05905cf 100644 --- a/ggml/src/ggml-backend-impl.h +++ b/ggml/src/ggml-backend-impl.h @@ -34,6 +34,11 @@ extern "C" { void * context; }; + // [TAG_ALLOC_SIZE_EXPAND] + // returns true for ops that may require additional memory for fleeting data on some backends, + // i.e. the backend buffer type's get_alloc_size may return more than ggml_nbytes for the output tensor + GGML_API bool ggml_op_alloc_size_may_expand(enum ggml_op op); + // // Backend buffer // diff --git a/ggml/src/ggml-backend.cpp b/ggml/src/ggml-backend.cpp index ffe20b9d0..6862128e6 100644 --- a/ggml/src/ggml-backend.cpp +++ b/ggml/src/ggml-backend.cpp @@ -71,7 +71,7 @@ size_t ggml_backend_buft_get_alloc_size(ggml_backend_buffer_type_t buft, const s GGML_ASSERT(size <= ggml_nbytes(tensor) || ggml_op_is_empty(tensor->op) || ggml_is_quantized(tensor->type) || // [TAG_ALLOC_SIZE_EXPAND] - ggml_backend_op_alloc_size_may_expand(tensor->op)); + ggml_op_alloc_size_may_expand(tensor->op)); return size; } @@ -2109,10 +2109,7 @@ ggml_backend_t ggml_backend_sched_get_tensor_backend(ggml_backend_sched_t sched, // utils -// [TAG_ALLOC_SIZE_EXPAND] -// returns true for ops that may require additional memory for fleeting data on some backends, -// i.e. the backend's get_alloc_size may return more than ggml_nbytes for the output tensor -bool ggml_backend_op_alloc_size_may_expand(enum ggml_op op) { +bool ggml_op_alloc_size_may_expand(enum ggml_op op) { switch (op) { case GGML_OP_FLASH_ATTN_EXT: case GGML_OP_MUL_MAT: diff --git a/ggml/src/ggml-rpc/ggml-rpc.cpp b/ggml/src/ggml-rpc/ggml-rpc.cpp index a97db24e6..cc7d72069 100644 --- a/ggml/src/ggml-rpc/ggml-rpc.cpp +++ b/ggml/src/ggml-rpc/ggml-rpc.cpp @@ -835,7 +835,7 @@ static size_t ggml_backend_rpc_buffer_type_get_alloc_size(ggml_backend_buffer_ty // [TAG_ALLOC_SIZE_EXPAND] // ops that may require additional memory for fleeting data on certain backends // ref: https://github.com/ggml-org/llama.cpp/pull/15966 - rpc_get |= ggml_backend_op_alloc_size_may_expand(tensor->op); + rpc_get |= ggml_op_alloc_size_may_expand(tensor->op); if (rpc_get) { ggml_backend_rpc_buffer_type_context * buft_ctx = (ggml_backend_rpc_buffer_type_context *)buft->context;