Skip to content

Commit 384ec34

Browse files
committed
Remove duplicate code
1 parent 3c92b07 commit 384ec34

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

LLama/Native/SafeMtmdModelHandle.cs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static SafeMtmdModelHandle LoadFromFile(string modelPath, LLamaWeights te
4040
// This provides better error messages that llama.cpp, which would throw an access violation exception in both cases.
4141
using (var fs = new FileStream(modelPath, FileMode.Open))
4242
if (!fs.CanRead)
43-
throw new InvalidOperationException($"Mtmd MMP Model file '{modelPath}' is not readable");
43+
throw new InvalidOperationException($"Mtmd Model file '{modelPath}' is not readable");
4444

4545
using var pathUtf8 = PinnedUtf8String.Create(modelPath) ?? throw new ArgumentNullException(nameof(modelPath));
4646

@@ -138,21 +138,13 @@ public int Tokenize(string text, bool addSpecial, bool parseSpecial, out SafeMtm
138138
if (result == 0)
139139
{
140140
chunks = new SafeMtmdInputChunks(output);
141-
foreach (var media in _pendingMedia)
142-
media.Dispose();
143-
_pendingMedia.Clear();
144141
}
145142
else
146143
{
147144
NativeApi.mtmd_input_chunks_free(output);
148145
}
149146

150-
if (result != 0)
151-
{
152-
foreach (var media in _pendingMedia)
153-
media.Dispose();
154-
_pendingMedia.Clear();
155-
}
147+
ClearMedia();
156148

157149
return result;
158150
}

0 commit comments

Comments
 (0)