diff --git a/ggml/src/ggml.c b/ggml/src/ggml.c index 0bdb71f70..47417c024 100644 --- a/ggml/src/ggml.c +++ b/ggml/src/ggml.c @@ -19202,6 +19202,7 @@ int ggml_graph_n_nodes(struct ggml_cgraph * cgraph) { } void ggml_graph_add_node(struct ggml_cgraph * cgraph, struct ggml_tensor * tensor) { + GGML_ASSERT(cgraph->size > cgraph->n_nodes); cgraph->nodes[cgraph->n_nodes] = tensor; cgraph->n_nodes++; }