Browse Source

- Split extension methods into separate files

tags/v0.6.0
Martin Evans 2 years ago
parent
commit
4e9b1f8cdc
2 changed files with 35 additions and 22 deletions
  1. +35
    -0
      LLama/Extensions/IContextParamsExtensions.cs
  2. +0
    -22
      LLama/Extensions/IModelParamsExtensions.cs

+ 35
- 0
LLama/Extensions/IContextParamsExtensions.cs View File

@@ -0,0 +1,35 @@
using System;
using System.IO;
using LLama.Abstractions;
using LLama.Native;

namespace LLama.Extensions
{
/// <summary>
/// Extention methods to the IContextParams interface
/// </summary>
public static class IContextParamsExtensions
{
/// <summary>
/// Convert the given `IModelParams` into a `LLamaContextParams`
/// </summary>
/// <param name="params"></param>
/// <param name="result"></param>
/// <returns></returns>
/// <exception cref="FileNotFoundException"></exception>
/// <exception cref="ArgumentException"></exception>
public static void ToLlamaContextParams(this IContextParams @params, out LLamaContextParams result)
{
result = NativeApi.llama_context_default_params();
result.n_ctx = @params.ContextSize;
result.n_batch = @params.BatchSize;
result.seed = @params.Seed;
result.f16_kv = @params.UseFp16Memory;
result.logits_all = @params.Perplexity;
result.embedding = @params.EmbeddingMode;
result.rope_freq_base = @params.RopeFrequencyBase;
result.rope_freq_scale = @params.RopeFrequencyScale;
result.mul_mat_q = @params.MulMatQ;
}
}
}

+ 0
- 22
LLama/Extensions/IModelParamsExtensions.cs View File

@@ -11,28 +11,6 @@ namespace LLama.Extensions
/// </summary> /// </summary>
public static class IModelParamsExtensions public static class IModelParamsExtensions
{ {
/// <summary>
/// Convert the given `IModelParams` into a `LLamaContextParams`
/// </summary>
/// <param name="params"></param>
/// <param name="result"></param>
/// <returns></returns>
/// <exception cref="FileNotFoundException"></exception>
/// <exception cref="ArgumentException"></exception>
public static void ToLlamaContextParams(this IContextParams @params, out LLamaContextParams result)
{
result = NativeApi.llama_context_default_params();
result.n_ctx = @params.ContextSize;
result.n_batch = @params.BatchSize;
result.seed = @params.Seed;
result.f16_kv = @params.UseFp16Memory;
result.logits_all = @params.Perplexity;
result.embedding = @params.EmbeddingMode;
result.rope_freq_base = @params.RopeFrequencyBase;
result.rope_freq_scale = @params.RopeFrequencyScale;
result.mul_mat_q = @params.MulMatQ;
}

/// <summary> /// <summary>
/// Convert the given `IModelParams` into a `LLamaModelParams` /// Convert the given `IModelParams` into a `LLamaModelParams`
/// </summary> /// </summary>


Loading…
Cancel
Save