From 2a2f39ef4523357cb7558526e579c399a50e4e73 Mon Sep 17 00:00:00 2001 From: Robyn Date: Sat, 17 Jun 2023 15:55:57 +1000 Subject: [PATCH] #1869 Fix null reference errors when training from scratch with CUDA build Calling ggml_compute_forward when node->src0 was null was causing train-text-from-scratch.exe to terminate unexpectedly. --- ggml.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ggml.c b/ggml.c index 0eda7f338..9a5f23c83 100644 --- a/ggml.c +++ b/ggml.c @@ -16012,7 +16012,9 @@ void ggml_graph_compute(struct ggml_context * ctx, struct ggml_cgraph * cgraph) /*.wdata =*/ cgraph->work ? cgraph->work->data : NULL, }; - ggml_compute_forward(¶ms, node); + if (node->src0) { + ggml_compute_forward(¶ms, node); + } // COMPUTE if (node->n_tasks > 1) { @@ -16048,7 +16050,9 @@ void ggml_graph_compute(struct ggml_context * ctx, struct ggml_cgraph * cgraph) } params.type = GGML_TASK_COMPUTE; - ggml_compute_forward(¶ms, node); + if (node->src0) { + ggml_compute_forward(¶ms, node); + } // wait for thread pool if (node->n_tasks > 1) { @@ -16103,7 +16107,9 @@ void ggml_graph_compute(struct ggml_context * ctx, struct ggml_cgraph * cgraph) } params.type = GGML_TASK_FINALIZE; - ggml_compute_forward(¶ms, node); + if (node->src0) { + ggml_compute_forward(¶ms, node); + } // wait for thread pool if (node->n_tasks > 1) {