浏览代码

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

Jesse Gross 2 月之前
父节点
当前提交
d223f3b697
共有 1 个文件被更改,包括 4 次插入2 次删除
  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() {
 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 {
 type Tensor struct {