Browse Source

- Cleaned up disposal in LLamaContext

- sealed some classes not intended to be extended
tags/v0.5.1
Martin Evans 2 years ago
parent
commit
d0a7a8fcd6
4 changed files with 7 additions and 6 deletions
  1. +4
    -3
      LLama/LLamaContext.cs
  2. +1
    -1
      LLama/LLamaWeights.cs
  3. +1
    -1
      LLama/Native/SafeLLamaContextHandle.cs
  4. +1
    -1
      LLama/Native/SafeLlamaModelHandle.cs

+ 4
- 3
LLama/LLamaContext.cs 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 />


+ 1
- 1
LLama/LLamaWeights.cs 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;


+ 1
- 1
LLama/Native/SafeLLamaContextHandle.cs 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


+ 1
- 1
LLama/Native/SafeLlamaModelHandle.cs 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>


Loading…
Cancel
Save