Output correct error message in ggml_new_tensor_impl when out of scratch space.

This commit is contained in:
KerfuffleV2 2023-05-07 03:52:37 -06:00
parent 89951748db
commit ab4f1fa8e2

2
ggml.c
View file

@ -4683,7 +4683,7 @@ struct ggml_tensor * ggml_new_tensor_impl(
size_t size_needed = 0;
if (!ggml_tensor_required_memory(ctx, type, n_dims, ne, data, &ctx_needed, &scratch_needed)) {
if (scratch_needed > 0 && ctx->scratch.size) {
if (scratch_needed > 0 && ctx->scratch.offs + scratch_needed > ctx->scratch.size) {
GGML_PRINT("%s: not enough space in the scratch memory (needed %zu, available %zu)\n",
__func__, ctx->scratch.offs + scratch_needed, ctx->scratch.size);
} else {