Skip to content

Commit

Permalink
Merge feat: add detection template for cuda and avx. SciSharp#268
Browse files Browse the repository at this point in the history
Just merge cuda and avx detection and change layout.
  • Loading branch information
SignalRT committed Nov 8, 2023
1 parent 091b8d5 commit b4b3ea9
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 26 deletions.
36 changes: 18 additions & 18 deletions LLama/LLamaSharp.Runtime.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,41 @@
<IncludeBuiltInRuntimes Condition="'$(IncludeBuiltInRuntimes)' == ''">true</IncludeBuiltInRuntimes>
</PropertyGroup>
<ItemGroup Condition="'$(IncludeBuiltInRuntimes)' == 'true'">
<None Include="$(MSBuildThisFileDirectory)runtimes/libllama.dll">
<None Include="$(MSBuildThisFileDirectory)runtimes/win-x64/libllama.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>libllama.dll</Link>
<Link>runtimes/win-x64/libllama.dll</Link>
</None>
<None Include="$(MSBuildThisFileDirectory)runtimes/libllama-cuda11.dll">
<None Include="$(MSBuildThisFileDirectory)runtimes/win-x64/libllama-cuda11.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>libllama-cuda11.dll</Link>
<Link>runtimes/win-x64/libllama-cuda11.dll</Link>
</None>
<None Include="$(MSBuildThisFileDirectory)runtimes/libllama-cuda12.dll">
<None Include="$(MSBuildThisFileDirectory)runtimes/win-x64/libllama-cuda12.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>libllama-cuda12.dll</Link>
<Link>runtimes/win-x64/libllama-cuda12.dll</Link>
</None>
<None Include="$(MSBuildThisFileDirectory)runtimes/libllama.so">
<None Include="$(MSBuildThisFileDirectory)runtimes/linux-x64/libllama.so">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>libllama.so</Link>
<Link>runtimes/linux-x64/libllama.so</Link>
</None>
<None Include="$(MSBuildThisFileDirectory)runtimes/libllama-cuda11.so">
<None Include="$(MSBuildThisFileDirectory)runtimes/linux-x64/libllama-cuda11.so">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>libllama-cuda11.so</Link>
<Link>runtimes/linux-x64/libllama-cuda11.so</Link>
</None>
<None Include="$(MSBuildThisFileDirectory)runtimes/libllama-cuda12.so">
<None Include="$(MSBuildThisFileDirectory)runtimes/linux-x64/libllama-cuda12.so">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>libllama-cuda12.so</Link>
<Link>runtimes/linux-x64/libllama-cuda12.so</Link>
</None>
<None Include="$(MSBuildThisFileDirectory)runtimes/macos-arm64/libllama.dylib">
<None Include="$(MSBuildThisFileDirectory)runtimes/osx-arm64/libllama.dylib">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>runtimes/macos-arm64/libllama.dylib</Link>
<Link>runtimes/osx-arm64/libllama.dylib</Link>
</None>
<None Include="$(MSBuildThisFileDirectory)runtimes/macos-arm64/ggml-metal.metal">
<None Include="$(MSBuildThisFileDirectory)runtimes/osx-arm64/ggml-metal.metal">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>runtimes/macos-arm64/ggml-metal.metal</Link>
<Link>runtimes/osx-arm64/ggml-metal.metal</Link>
</None>
<None Include="$(MSBuildThisFileDirectory)runtimes/macos-x86_64/libllama.dylib">
<None Include="$(MSBuildThisFileDirectory)runtimes/osx-x64/libllama.dylib">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>runtimes/macos-x86_64/libllama.dylib</Link>
<Link>runtimes/osx-x64/libllama.dylib</Link>
</None>
</ItemGroup>
</Project>
16 changes: 8 additions & 8 deletions LLama/Native/NativeApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@ private static IntPtr LLamaImportResolver(string name, Assembly assembly, DllImp
var cudaVersion = GetCudaVersion();
if(cudaVersion == 11)
{
libraryPath = $"runtimes/win-x64/native/libllama-cuda11{avxFlag}.dll";
libraryPath = $"runtimes/win-x64/libllama-cuda11{avxFlag}.dll";
}
else if (cudaVersion == 12)
{
libraryPath = $"runtimes/win-x64/native/libllama-cuda12{avxFlag}.dll";
libraryPath = $"runtimes/win-x64/libllama-cuda12{avxFlag}.dll";
}
else if(cudaVersion == -1) // cpu version
{
libraryPath = $"runtimes/win-x64/native/libllama{avxFlag}.dll";
libraryPath = $"runtimes/win-x64/libllama{avxFlag}.dll";
}
else
{
Expand All @@ -132,15 +132,15 @@ private static IntPtr LLamaImportResolver(string name, Assembly assembly, DllImp
var cudaVersion = GetCudaVersion();
if (cudaVersion == 11)
{
libraryPath = $"runtimes/linux-x64/native/libllama-cuda11{avxFlag}.so";
libraryPath = $"runtimes/linux-x64/libllama-cuda11{avxFlag}.so";
}
else if (cudaVersion == 12)
{
libraryPath = $"runtimes/linux-x64/native/libllama-cuda12{avxFlag}.so";
libraryPath = $"runtimes/linux-x64/libllama-cuda12{avxFlag}.so";
}
else if (cudaVersion == -1) // cpu version
{
libraryPath = $"runtimes/linux-x64/native/libllama{avxFlag}.so";
libraryPath = $"runtimes/linux-x64/libllama{avxFlag}.so";
}
else
{
Expand All @@ -151,11 +151,11 @@ private static IntPtr LLamaImportResolver(string name, Assembly assembly, DllImp
{
if (System.Runtime.Intrinsics.Arm.ArmBase.Arm64.IsSupported)
{
libraryPath = $"runtimes/osx-arm64/native/libllama.dylib";
libraryPath = $"runtimes/osx-arm64/libllama.dylib";
}
else
{
libraryPath = $"runtimes/osx-x64/native/libllama.dylib";
libraryPath = $"runtimes/osx-x86_64/libllama.dylib";
}
}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit b4b3ea9

Please sign in to comment.