diff --git a/LLama.Unittest/BasicTest.cs b/LLama.Unittest/BasicTest.cs
index 64fa4d0f..1d54a7e9 100644
--- a/LLama.Unittest/BasicTest.cs
+++ b/LLama.Unittest/BasicTest.cs
@@ -18,7 +18,7 @@ namespace LLama.Unittest
_params = new ModelParams(Constants.GenerativeModelPath)
{
ContextSize = 2048,
- GpuLayerCount = 0
+ GpuLayerCount = Constants.CIGpuLayerCount
};
_model = LLamaWeights.LoadFromFile(_params);
}
diff --git a/LLama.Unittest/BeamTests.cs b/LLama.Unittest/BeamTests.cs
index 6ae0adbf..88b25672 100644
--- a/LLama.Unittest/BeamTests.cs
+++ b/LLama.Unittest/BeamTests.cs
@@ -18,7 +18,7 @@ public sealed class BeamTests
_params = new ModelParams(Constants.GenerativeModelPath)
{
ContextSize = 2048,
- GpuLayerCount = 0,
+ GpuLayerCount = Constants.CIGpuLayerCount,
};
_model = LLamaWeights.LoadFromFile(_params);
}
diff --git a/LLama.Unittest/Constants.cs b/LLama.Unittest/Constants.cs
index 6e5e92c5..8a496f6e 100644
--- a/LLama.Unittest/Constants.cs
+++ b/LLama.Unittest/Constants.cs
@@ -1,4 +1,6 @@
-namespace LLama.Unittest
+using System.Runtime.InteropServices;
+
+namespace LLama.Unittest
{
internal static class Constants
{
@@ -8,5 +10,25 @@
public static readonly string LLavaModelPath = "Models/llava-v1.6-mistral-7b.Q3_K_XS.gguf";
public static readonly string LLavaMmpPath = "Models/mmproj-model-f16.gguf";
public static readonly string LLavaImage = "Models/extreme-ironing-taxi-610x427.jpg";
+
+ ///
+ /// Calculate GpuLayer Count to use in UnitTest
+ ///
+ /// Defaults to 20 in all the cases, except IOS release (to disable METAL on github CI)
+ public static int CIGpuLayerCount
+ {
+ get
+ {
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ {
+ #if DEBUG
+ return 20;
+ #else
+ return 0;
+ #endif
+ }
+ else return 20;
+ }
+ }
}
}
diff --git a/LLama.Unittest/GrammarTest.cs b/LLama.Unittest/GrammarTest.cs
index db4372b0..d4f6a95b 100644
--- a/LLama.Unittest/GrammarTest.cs
+++ b/LLama.Unittest/GrammarTest.cs
@@ -16,7 +16,7 @@ namespace LLama.Unittest
{
ContextSize = 2048,
Seed = 92,
- GpuLayerCount = 0,
+ GpuLayerCount = Constants.CIGpuLayerCount,
};
_model = LLamaWeights.LoadFromFile(_params);
}
diff --git a/LLama.Unittest/LLamaContextTests.cs b/LLama.Unittest/LLamaContextTests.cs
index bd02ef7b..cc53e369 100644
--- a/LLama.Unittest/LLamaContextTests.cs
+++ b/LLama.Unittest/LLamaContextTests.cs
@@ -14,7 +14,7 @@ namespace LLama.Unittest
var @params = new ModelParams(Constants.GenerativeModelPath)
{
ContextSize = 768,
- GpuLayerCount = 0
+ GpuLayerCount = Constants.CIGpuLayerCount,
};
_weights = LLamaWeights.LoadFromFile(@params);
_context = _weights.CreateContext(@params);
diff --git a/LLama.Unittest/LLamaEmbedderTests.cs b/LLama.Unittest/LLamaEmbedderTests.cs
index 604e2bd1..570c6c12 100644
--- a/LLama.Unittest/LLamaEmbedderTests.cs
+++ b/LLama.Unittest/LLamaEmbedderTests.cs
@@ -19,7 +19,7 @@ public sealed class LLamaEmbedderTests
ContextSize = 4096,
Threads = 5,
Embeddings = true,
- GpuLayerCount = 0
+ GpuLayerCount = Constants.CIGpuLayerCount,
};
using var weights = LLamaWeights.LoadFromFile(@params);
_embedder = new(weights, @params);
diff --git a/LLama.Unittest/LLavaWeightsTests.cs b/LLama.Unittest/LLavaWeightsTests.cs
index 2c21a7a1..30d41fd9 100644
--- a/LLama.Unittest/LLavaWeightsTests.cs
+++ b/LLama.Unittest/LLavaWeightsTests.cs
@@ -18,7 +18,7 @@ namespace LLama.Unittest
{
// Llava models requires big context
ContextSize = 4096,
- GpuLayerCount = 0
+ GpuLayerCount = Constants.CIGpuLayerCount,
};
_llamaWeights = LLamaWeights.LoadFromFile(@params);
_lLavaWeights = LLavaWeights.LoadFromFile(Constants.LLavaMmpPath);
diff --git a/LLama.Unittest/MemoryDisposalTests.cs b/LLama.Unittest/MemoryDisposalTests.cs
index 1bcc7edc..60cd75fd 100644
--- a/LLama.Unittest/MemoryDisposalTests.cs
+++ b/LLama.Unittest/MemoryDisposalTests.cs
@@ -25,7 +25,7 @@ public class MemoryDisposalTests
var @params = new ModelParams(Constants.GenerativeModelPath)
{
ContextSize = 2048,
- GpuLayerCount = 0
+ GpuLayerCount = Constants.CIGpuLayerCount,
};
var model = LLamaWeights.LoadFromFile(@params);
diff --git a/LLama.Unittest/StatelessExecutorTest.cs b/LLama.Unittest/StatelessExecutorTest.cs
index ab979471..18f3c25d 100644
--- a/LLama.Unittest/StatelessExecutorTest.cs
+++ b/LLama.Unittest/StatelessExecutorTest.cs
@@ -20,7 +20,7 @@ namespace LLama.Unittest
ContextSize = 60,
Seed = 1754,
BatchSize = 2,
- GpuLayerCount = 0,
+ GpuLayerCount = Constants.CIGpuLayerCount,
};
_weights = LLamaWeights.LoadFromFile(_params);
}
diff --git a/LLama.Unittest/TokenTests.cs b/LLama.Unittest/TokenTests.cs
index 19118bf8..03e3927f 100644
--- a/LLama.Unittest/TokenTests.cs
+++ b/LLama.Unittest/TokenTests.cs
@@ -15,7 +15,7 @@ public sealed class TokenTests
_params = new ModelParams(Constants.GenerativeModelPath)
{
ContextSize = 2048,
- GpuLayerCount = 0,
+ GpuLayerCount = Constants.CIGpuLayerCount,
};
_model = LLamaWeights.LoadFromFile(_params);
}