diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..b00368fb --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,55 @@ +name: CI +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + build: + name: Test + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + build: [linux-debug, linux-release, macos-debug, macos-release, windows-debug, windows-release] + include: + - build: linux-debug + os: ubuntu-latest + config: debug + - build: linux-release + os: ubuntu-latest + config: release + - build: macos-debug + os: macos-latest + config: debug + - build: macos-release + os: macos-latest + config: release + - build: windows-debug + os: windows-2019 + config: debug + - build: windows-release + os: windows-2019 + config: release + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-dotnet@v1 + with: + dotnet-version: | + 6.0.x + 7.0.x + - name: Cache Gradle packages + uses: actions/cache@v3 + with: + key: "unit_test_models" + path: LLama.Unittest/Models + # workaround for actions/setup-dotnet#155 + - name: Clear package cache + run: dotnet clean LLamaSharp.sln && dotnet nuget locals all --clear + - name: Restore packages + run: dotnet restore LLamaSharp.sln + - name: Build + run: dotnet build LLamaSharp.sln -c ${{ matrix.config }} --no-restore + - name: Test + run: dotnet test LLamaSharp.sln -c ${{ matrix.config }} diff --git a/.gitignore b/.gitignore index d1d0ba40..2f38fac0 100644 --- a/.gitignore +++ b/.gitignore @@ -341,4 +341,5 @@ test/TensorFlowNET.Examples/mnist *.xsd # docs -site/ \ No newline at end of file +site/ +/LLama.Unittest/Models/*.bin diff --git a/LLama.Unittest/BasicTest.cs b/LLama.Unittest/BasicTest.cs index 29178432..fd602cf0 100644 --- a/LLama.Unittest/BasicTest.cs +++ b/LLama.Unittest/BasicTest.cs @@ -1,11 +1,14 @@ +using LLama.Common; + namespace LLama.Unittest { public class BasicTest { [Fact] - public void SimpleQA() + public void LoadModel() { - + var model = new LLamaModel(new ModelParams("Models/llama-2-7b-chat.ggmlv3.q3_K_S.bin", contextSize: 256)); + model.Dispose(); } } } \ No newline at end of file diff --git a/LLama.Unittest/LLama.Unittest.csproj b/LLama.Unittest/LLama.Unittest.csproj index 93922e81..65dbd161 100644 --- a/LLama.Unittest/LLama.Unittest.csproj +++ b/LLama.Unittest/LLama.Unittest.csproj @@ -23,8 +23,23 @@ + + + + + + + + + + + + PreserveNewest + + + diff --git a/LLama/Common/FixedSizeQueue.cs b/LLama/Common/FixedSizeQueue.cs index e059ef70..4b082feb 100644 --- a/LLama/Common/FixedSizeQueue.cs +++ b/LLama/Common/FixedSizeQueue.cs @@ -30,9 +30,11 @@ namespace LLama.Common /// public FixedSizeQueue(int size, IEnumerable data) { +#if NETCOREAPP3_0_OR_GREATER // Try an early check on the amount of data supplied (if possible) if (data.TryGetNonEnumeratedCount(out var count) && count > size) throw new ArgumentException($"The max size set for the quene is {size}, but got {count} initial values."); +#endif // Size of "data" is unknown, copy it all into a list _maxSize = size; @@ -40,7 +42,7 @@ namespace LLama.Common // Now check if that list is a valid size if (_storage.Count > _maxSize) - throw new ArgumentException($"The max size set for the quene is {size}, but got {count} initial values."); + throw new ArgumentException($"The max size set for the quene is {size}, but got {_storage.Count} initial values."); } ///