From b7cb3bb76fbe3f0b014c0f9ac0e848fcd2b0913c Mon Sep 17 00:00:00 2001 From: ngxson Date: Wed, 27 Mar 2024 15:51:38 +0100 Subject: [PATCH] error on 0 tensors --- examples/gguf-split/gguf-split.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/examples/gguf-split/gguf-split.cpp b/examples/gguf-split/gguf-split.cpp index 044d63a67..d0765bc2c 100644 --- a/examples/gguf-split/gguf-split.cpp +++ b/examples/gguf-split/gguf-split.cpp @@ -66,6 +66,9 @@ static size_t split_str_to_n_bytes(std::string str) { } else { throw std::invalid_argument("error: supported units are M (megabytes) or G (gigabytes), but got: " + std::string(1, str.back())); } + if (n <= 0) { + throw std::invalid_argument("error: size must be a negative value"); + } return n_bytes; } @@ -200,6 +203,10 @@ struct split_strategy { auto new_ctx_out = [&]() { i_split++; if (ctx_out != NULL) { + if (gguf_get_n_tensors(ctx_out) == 0) { + fprintf(stderr, "error: one of splits have 0 tensors. Maybe size or tensors limit is too small\n"); + exit(EXIT_FAILURE); + } ctx_outs.push_back(ctx_out); } ctx_out = gguf_init_empty();