Skip to content

Refactor: Upgrade to .NET 8 #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Aug 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions Demos/Converter/App.config

This file was deleted.

2 changes: 0 additions & 2 deletions Demos/Converter/CommonLib/ConfigLoader.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using System.IO;

namespace Converter.CommonLib
{
Expand Down
1 change: 0 additions & 1 deletion Demos/Converter/CommonLib/Sentencepiece.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using ProtoBuf;
using System.Collections.Generic;

namespace Converter.CommonLib
{
Expand Down
4 changes: 0 additions & 4 deletions Demos/Converter/CommonTensorConverterDemo.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using GGMLSharp;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Converter
{
Expand Down
94 changes: 17 additions & 77 deletions Demos/Converter/Converter.csproj
Original file line number Diff line number Diff line change
@@ -1,91 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{422A11E6-EFB2-4486-85A8-3B2CC9692FA8}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Converter</RootNamespace>
<AssemblyName>Converter</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>

<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="protobuf-net" Version="3.2.30" />
<PackageReference Include="System.IO.Compression.ZipFile" Version="4.3.0" />
</ItemGroup>

<ItemGroup>
<Compile Include="Abstractions\IPickleConverter.cs" />
<Compile Include="Abstractions\ISafeTensorConverter.cs" />
<Compile Include="CommonTensorConverterDemo.cs" />
<Compile Include="Pickle\Llama3.cs" />
<Compile Include="CommonLib\ConfigLoader.cs" />
<Compile Include="CommonLib\DataTrans.cs" />
<Compile Include="CommonLib\Sentencepiece.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Safetensors\Llama.cs" />
<Compile Include="Safetensors\Qwen.cs" />
<ProjectReference Include="..\..\GGMLSharp\GGMLSharp.csproj" />
<ProjectReference Include="..\ModelLoader\ModelLoader.csproj" />
</ItemGroup>

<ItemGroup>
<None Include="App.config" />
<None Include="Assets\model.pt">
<None Update="Assets\model.pt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Assets\taesd.safetensors">
<None Update="Assets\taesd.safetensors">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\GGMLSharp\GGMLSharp.csproj">
<Project>{001fd1f1-ec17-45e9-b750-a2a2029e6c60}</Project>
<Name>GGMLSharp</Name>
</ProjectReference>
<ProjectReference Include="..\ModelLoader\ModelLoader.csproj">
<Project>{e48f9d97-86ef-42cd-be41-46365026bee7}</Project>
<Name>ModelLoader</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json">
<Version>13.0.3</Version>
</PackageReference>
<PackageReference Include="protobuf-net">
<Version>3.2.30</Version>
</PackageReference>
<PackageReference Include="System.IO.Compression.ZipFile">
<Version>4.3.0</Version>
</PackageReference>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

</Project>
4 changes: 0 additions & 4 deletions Demos/Converter/Pickle/Llama3.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
using Converter.Abstractions;
using Converter.CommonLib;
using GGMLSharp;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;

Expand Down
10 changes: 5 additions & 5 deletions Demos/Converter/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ static void Main(string[] args)
// Tested Qwen model link is from https://huggingface.co/Qwen/Qwen1.5-1.8B-Chat
// Tested LLama3 model link is from https://huggingface.co/bineric/NorskGPT-Llama3-8b/tree/main

//new Safetensors.Qwen().Convert(@".\models\qwen", "qwen.gguf");
//new Safetensors.Llama().Convert(@".\models\open_llama", "open_llama.gguf");
//new Pickle.Llama3().Convert(@".\models\NorskGPT-Llama3-8b", "NorskGPT-Llama3-8b.gguf");
//new Safetensors.Qwen().Convert(@"./models/qwen", "qwen.gguf");
//new Safetensors.Llama().Convert(@"./models/open_llama", "open_llama.gguf");
//new Pickle.Llama3().Convert("./models/NorskGPT-Llama3-8b", "NorskGPT-Llama3-8b.gguf");

new CommonTensorConverterDemo().ConvertToGguf(@".\Assets\model.pt", "model.gguf", CommonTensorConverterDemo.ModelType.Pickle, true);
//new CommonTensorConverterDemo().ConvertToGguf(@".\Assets\taesd.safetensors", "taesd.gguf", CommonTensorConverterDemo.ModelType.Safetensors, false);
new CommonTensorConverterDemo().ConvertToGguf("./Assets/model.pt", "model.gguf", CommonTensorConverterDemo.ModelType.Pickle, true);
//new CommonTensorConverterDemo().ConvertToGguf("./Assets/taesd.safetensors", "taesd.gguf", CommonTensorConverterDemo.ModelType.Safetensors, false);

}
}
Expand Down
36 changes: 0 additions & 36 deletions Demos/Converter/Properties/AssemblyInfo.cs

This file was deleted.

4 changes: 0 additions & 4 deletions Demos/Converter/Safetensors/Llama.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
using Converter.CommonLib;
using GGMLSharp;
using ProtoBuf;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using static GGMLSharp.Structs;
Expand Down
4 changes: 0 additions & 4 deletions Demos/Converter/Safetensors/Qwen.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
using Converter.Abstractions;
using Converter.CommonLib;
using GGMLSharp;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;

Expand Down
6 changes: 0 additions & 6 deletions Demos/MNIST_CNN/App.config

This file was deleted.

8 changes: 2 additions & 6 deletions Demos/MNIST_CNN/Program.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using GGMLSharp;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static GGMLSharp.Structs;

namespace MNIST_CNN
Expand All @@ -11,8 +7,8 @@ internal class Program
{
static void Main(string[] args)
{
Model model = LoadModel(@".\Assets\mnist-cnn-model.gguf");
byte[] bytes = File.ReadAllBytes(@".\Assets\image.raw");
Model model = LoadModel("./Assets/mnist-cnn-model.gguf");
byte[] bytes = File.ReadAllBytes("./Assets/image.raw");
Console.WriteLine("The image is:");
for (int i = 0; i < 28; i++)
{
Expand Down
36 changes: 0 additions & 36 deletions Demos/MNIST_CNN/Properties/AssemblyInfo.cs

This file was deleted.

71 changes: 13 additions & 58 deletions Demos/MNIST_CNN/mnist_cnn.csproj
Original file line number Diff line number Diff line change
@@ -1,69 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{9D9440D2-EEAD-42D6-BA7B-D9E1658575ED}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>MNIST_CNN</RootNamespace>
<AssemblyName>MNIST_CNN</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>

<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<ProjectReference Include="..\..\GGMLSharp\GGMLSharp.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="Assets\mnist-cnn-model.gguf">
<None Update="Assets\image.raw">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\GGMLSharp\GGMLSharp.csproj">
<Project>{001fd1f1-ec17-45e9-b750-a2a2029e6c60}</Project>
<Name>GGMLSharp</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="Assets\image.raw">
<None Update="Assets\mnist-cnn-model.gguf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="readme_graph.png" />
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

</Project>
6 changes: 0 additions & 6 deletions Demos/MNIST_CPU/App.config

This file was deleted.

Loading