]> git.djapps.eu Git - pkg/ggml/sources/ggml/commitdiff
ggml : fix invalid src0 dereference
authorGeorgi Gerganov <redacted>
Sun, 25 Jun 2023 13:39:57 +0000 (16:39 +0300)
committerGeorgi Gerganov <redacted>
Sun, 25 Jun 2023 13:39:57 +0000 (16:39 +0300)
src/ggml-cuda.cu
src/ggml.c

index 36a251ecce973bddee7df398cd61931fbed22cf9..010682edb703cbbf1282b0ab76e5298132662f49 100644 (file)
@@ -2635,7 +2635,7 @@ void ggml_cuda_free_scratch() {
 bool ggml_cuda_compute_forward(struct ggml_compute_params * params, struct ggml_tensor * tensor){
     ggml_cuda_func_t func;
     const bool any_on_device = tensor->backend == GGML_BACKEND_GPU
-        || tensor->src0->backend == GGML_BACKEND_GPU || tensor->src0->backend == GGML_BACKEND_GPU_SPLIT
+        || (tensor->src0 != nullptr && (tensor->src0->backend == GGML_BACKEND_GPU || tensor->src0->backend == GGML_BACKEND_GPU_SPLIT))
         || (tensor->src1 != nullptr && tensor->src1->backend == GGML_BACKEND_GPU);
 
     switch (tensor->op) {
index 2a5c469ed8ea56fb5bc64af259fc0ed2b89e730e..1a441eb9874df068402b4a78d86f65c4a0cbdd63 100644 (file)
@@ -15194,7 +15194,7 @@ static void ggml_compute_forward(struct ggml_compute_params * params, struct ggm
     if (skip_cpu) {
         return;
     }
-    GGML_ASSERT(tensor->src0->backend == GGML_BACKEND_CPU);
+    GGML_ASSERT(tensor->src0 == NULL || tensor->src0->backend == GGML_BACKEND_CPU);
     GGML_ASSERT(tensor->src1 == NULL || tensor->src1->backend == GGML_BACKEND_CPU);
 #endif // GGML_USE_CUBLAS