- Cleaned up disposal in LLamaContext

- sealed some classes not intended to be extended
This commit is contained in:
Martin Evans 2023-08-09 00:35:32 +01:00
parent 4d741d24f2
commit d0a7a8fcd6
4 changed files with 7 additions and 6 deletions

View File

@ -422,6 +422,8 @@ namespace LLama
/// <inheritdoc />
public virtual void Dispose()
{
GC.SuppressFinalize(this);
_ctx.Dispose();
}
@ -429,12 +431,11 @@ namespace LLama
/// The state of this model, which can be reloaded later
/// </summary>
public class State
: SafeHandleZeroOrMinusOneIsInvalid
: SafeLLamaHandleBase
{
internal State(IntPtr memory)
: base(true)
: base(memory)
{
SetHandle(memory);
}
/// <inheritdoc />

View File

@ -9,7 +9,7 @@ namespace LLama
/// <summary>
/// A set of model weights, loaded into memory.
/// </summary>
public class LLamaWeights
public sealed class LLamaWeights
: IDisposable
{
private readonly SafeLlamaModelHandle _weights;

View File

@ -8,7 +8,7 @@ namespace LLama.Native
/// <summary>
/// A safe wrapper around a llama_context
/// </summary>
public class SafeLLamaContextHandle
public sealed class SafeLLamaContextHandle
: SafeLLamaHandleBase
{
#region properties and fields

View File

@ -7,7 +7,7 @@ namespace LLama.Native
/// <summary>
/// A reference to a set of llama model weights
/// </summary>
public class SafeLlamaModelHandle
public sealed class SafeLlamaModelHandle
: SafeLLamaHandleBase
{
/// <summary>