Skip to content

Commit 6701d16

Browse files
ggerganovjikunshang
authored andcommitted
ggml : allow ggml_init with 0 size
1 parent b2a0939 commit 6701d16

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

ggml.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4579,6 +4579,11 @@ struct ggml_context * ggml_init(struct ggml_init_params params) {
45794579
return NULL;
45804580
}
45814581

4582+
// allow to call ggml_init with 0 size
4583+
if (params.mem_size == 0) {
4584+
params.mem_size = GGML_MEM_ALIGN;
4585+
}
4586+
45824587
const size_t mem_size = params.mem_buffer ? params.mem_size : GGML_PAD(params.mem_size, GGML_MEM_ALIGN);
45834588

45844589
*ctx = (struct ggml_context) {

llama.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5406,7 +5406,7 @@ void llama_backend_init(bool numa) {
54065406

54075407
// needed to initialize f16 tables
54085408
{
5409-
struct ggml_init_params params = { 1, NULL, false };
5409+
struct ggml_init_params params = { 0, NULL, false };
54105410
struct ggml_context * ctx = ggml_init(params);
54115411
ggml_free(ctx);
54125412
}

0 commit comments

Comments
 (0)