From 2fce80288f19681ac83a626dbefa33312a90a706 Mon Sep 17 00:00:00 2001 From: Michael Yang Date: Thu, 3 Apr 2025 09:59:03 -0700 Subject: [PATCH] close temporary context --- model/models/mistral3/model_text.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/model/models/mistral3/model_text.go b/model/models/mistral3/model_text.go index fbafc31c5..f8de30c73 100644 --- a/model/models/mistral3/model_text.go +++ b/model/models/mistral3/model_text.go @@ -112,8 +112,10 @@ func (m *TextModel) Forward(ctx ml.Context, inputs, positions, outputs ml.Tensor row := image.Multimodal.(*imageRow) row.parent.dataOnce.Do(func() { // use a new, throwaway context so the image tensor is not added to the graph - m.Backend().NewContext().Forward(row.parent.tensor).Compute(row.parent.tensor) + temp := m.Backend().NewContext() + temp.Forward(row.parent.tensor).Compute(row.parent.tensor) row.parent.data = row.parent.tensor.Floats() + temp.Close() }) imageFeature, err := ctx.Input().FromFloatSlice(row.data(), row.shape...)