Browse Source

Merge pull request #74 from martindevans/github_actions

GitHub actions
tags/v0.4.2-preview
Martin Evans GitHub 3 years ago
parent
commit
b2ef8e6a26
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 80 additions and 4 deletions
  1. +55
    -0
      .github/workflows/main.yml
  2. +2
    -1
      .gitignore
  3. +5
    -2
      LLama.Unittest/BasicTest.cs
  4. +15
    -0
      LLama.Unittest/LLama.Unittest.csproj
  5. +3
    -1
      LLama/Common/FixedSizeQueue.cs

+ 55
- 0
.github/workflows/main.yml View File

@@ -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 }}

+ 2
- 1
.gitignore View File

@@ -341,4 +341,5 @@ test/TensorFlowNET.Examples/mnist
*.xsd

# docs
site/
site/
/LLama.Unittest/Models/*.bin

+ 5
- 2
LLama.Unittest/BasicTest.cs View File

@@ -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();
}
}
}

+ 15
- 0
LLama.Unittest/LLama.Unittest.csproj View File

@@ -23,8 +23,23 @@
</PackageReference>
</ItemGroup>

<Target Name="DownloadContentFiles" BeforeTargets="Build">
<DownloadFile SourceUrl="https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGML/resolve/main/llama-2-7b-chat.ggmlv3.q3_K_S.bin" DestinationFolder="Models" DestinationFileName="llama-2-7b-chat.ggmlv3.q3_K_S.bin" SkipUnchangedFiles="true">
</DownloadFile>
</Target>

<ItemGroup>
<ProjectReference Include="..\LLama\LLamaSharp.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Models\" />
</ItemGroup>

<ItemGroup>
<None Update="Models\llama-2-7b-chat.ggmlv3.q3_K_S.bin">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>

+ 3
- 1
LLama/Common/FixedSizeQueue.cs View File

@@ -30,9 +30,11 @@ namespace LLama.Common
/// <param name="data"></param>
public FixedSizeQueue(int size, IEnumerable<T> 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.");
}

/// <summary>


Loading…
Cancel
Save