diff --git a/LLama/Abstractions/IModelParams.cs b/LLama/Abstractions/IModelParams.cs
index 2ecfe49c..4a3dde7a 100644
--- a/LLama/Abstractions/IModelParams.cs
+++ b/LLama/Abstractions/IModelParams.cs
@@ -3,6 +3,9 @@ using System.Buffers;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
+using System.Text.Json;
+using System.Text.Json.Serialization;
+using LLama.Common;
using LLama.Native;
namespace LLama.Abstractions
@@ -105,6 +108,7 @@ namespace LLama.Abstractions
///
/// A fixed size array to set the tensor splits across multiple GPUs
///
+ [JsonConverter(typeof(TensorSplitsCollectionConverter))]
public sealed class TensorSplitsCollection
: IEnumerable
{
@@ -174,4 +178,24 @@ namespace LLama.Abstractions
}
#endregion
}
+
+ ///
+ /// A JSON converter for
+ ///
+ public class TensorSplitsCollectionConverter
+ : JsonConverter
+ {
+ ///
+ public override TensorSplitsCollection? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
+ {
+ var arr = JsonSerializer.Deserialize(ref reader, options) ?? Array.Empty();
+ return new TensorSplitsCollection(arr);
+ }
+
+ ///
+ public override void Write(Utf8JsonWriter writer, TensorSplitsCollection value, JsonSerializerOptions options)
+ {
+ JsonSerializer.Serialize(writer, value.Splits, options);
+ }
+ }
}
\ No newline at end of file
diff --git a/LLama/Common/ModelParams.cs b/LLama/Common/ModelParams.cs
index 25e638ad..cecd655a 100644
--- a/LLama/Common/ModelParams.cs
+++ b/LLama/Common/ModelParams.cs
@@ -59,7 +59,6 @@ namespace LLama.Common
public bool EmbeddingMode { get; set; }
///
- [JsonConverter(typeof(TensorSplitsCollectionConverter))]
public TensorSplitsCollection TensorSplits { get; set; } = new();
///
@@ -123,20 +122,4 @@ namespace LLama.Common
ModelPath = "";
}
}
-
-
- internal class TensorSplitsCollectionConverter
- : JsonConverter
- {
- public override TensorSplitsCollection? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
- {
- var arr = JsonSerializer.Deserialize(ref reader, options) ?? Array.Empty();
- return new TensorSplitsCollection(arr);
- }
-
- public override void Write(Utf8JsonWriter writer, TensorSplitsCollection value, JsonSerializerOptions options)
- {
- JsonSerializer.Serialize(writer, value.Splits, options);
- }
- }
}