Browse Source

ggml-backend: Close on nil should be a no-op

Jesse Gross 2 months ago
parent
commit
d223f3b697
1 changed files with 4 additions and 2 deletions
  1. 4 2
      ml/backend/ggml/ggml.go

+ 4 - 2
ml/backend/ggml/ggml.go

@@ -327,8 +327,10 @@ func (c Context) FromIntSlice(s []int32, shape ...int) (ml.Tensor, error) {
 }
 
 func (c *Context) Close() {
-	C.ggml_backend_sched_free(c.sched)
-	C.ggml_free(c.ctx)
+	if c != nil {
+		C.ggml_backend_sched_free(c.sched)
+		C.ggml_free(c.ctx)
+	}
 }
 
 type Tensor struct {