| @@ -129,31 +129,33 @@ namespace LLama.Native | |||||
| } | } | ||||
| #if NET6_0_OR_GREATER | #if NET6_0_OR_GREATER | ||||
| private static string GetAvxLibraryPath(NativeLibraryConfig.AvxLevel avxLevel, string prefix, string suffix) | |||||
| private static string GetAvxLibraryPath(NativeLibraryConfig.AvxLevel avxLevel, string prefix, string suffix, string libraryNamePrefix) | |||||
| { | { | ||||
| var avxStr = NativeLibraryConfig.AvxLevelToString(avxLevel); | var avxStr = NativeLibraryConfig.AvxLevelToString(avxLevel); | ||||
| if (!string.IsNullOrEmpty(avxStr)) | if (!string.IsNullOrEmpty(avxStr)) | ||||
| { | { | ||||
| avxStr += "/"; | avxStr += "/"; | ||||
| } | } | ||||
| return $"{prefix}{avxStr}{libraryName}{suffix}"; | |||||
| return $"{prefix}{avxStr}{libraryNamePrefix}{libraryName}{suffix}"; | |||||
| } | } | ||||
| private static List<string> GetLibraryTryOrder(NativeLibraryConfig.Description configuration) | private static List<string> GetLibraryTryOrder(NativeLibraryConfig.Description configuration) | ||||
| { | { | ||||
| OSPlatform platform; | OSPlatform platform; | ||||
| string prefix, suffix; | |||||
| string prefix, suffix, libraryNamePrefix; | |||||
| if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) | if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) | ||||
| { | { | ||||
| platform = OSPlatform.Windows; | platform = OSPlatform.Windows; | ||||
| prefix = "runtimes/win-x64/native/"; | prefix = "runtimes/win-x64/native/"; | ||||
| suffix = ".dll"; | suffix = ".dll"; | ||||
| libraryNamePrefix = ""; | |||||
| } | } | ||||
| else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) | else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) | ||||
| { | { | ||||
| platform = OSPlatform.Linux; | platform = OSPlatform.Linux; | ||||
| prefix = "runtimes/linux-x64/native/"; | prefix = "runtimes/linux-x64/native/"; | ||||
| suffix = ".so"; | suffix = ".so"; | ||||
| libraryNamePrefix = "lib"; | |||||
| } | } | ||||
| else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) | else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) | ||||
| { | { | ||||
| @@ -163,6 +165,7 @@ namespace LLama.Native | |||||
| prefix = System.Runtime.Intrinsics.Arm.ArmBase.Arm64.IsSupported | prefix = System.Runtime.Intrinsics.Arm.ArmBase.Arm64.IsSupported | ||||
| ? "runtimes/osx-arm64/native/" | ? "runtimes/osx-arm64/native/" | ||||
| : "runtimes/osx-x64/native/"; | : "runtimes/osx-x64/native/"; | ||||
| libraryNamePrefix = "lib"; | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -181,8 +184,8 @@ namespace LLama.Native | |||||
| // if check skipped, we just try to load cuda libraries one by one. | // if check skipped, we just try to load cuda libraries one by one. | ||||
| if (configuration.SkipCheck) | if (configuration.SkipCheck) | ||||
| { | { | ||||
| result.Add($"{prefix}cuda12/{libraryName}{suffix}"); | |||||
| result.Add($"{prefix}cuda11/{libraryName}{suffix}"); | |||||
| result.Add($"{prefix}cuda12/{libraryNamePrefix}{libraryName}{suffix}"); | |||||
| result.Add($"{prefix}cuda11/{libraryNamePrefix}{libraryName}{suffix}"); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -209,25 +212,25 @@ namespace LLama.Native | |||||
| // use cpu (or mac possibly with metal) | // use cpu (or mac possibly with metal) | ||||
| if (!configuration.AllowFallback && platform != OSPlatform.OSX) | if (!configuration.AllowFallback && platform != OSPlatform.OSX) | ||||
| { | { | ||||
| result.Add(GetAvxLibraryPath(configuration.AvxLevel, prefix, suffix)); | |||||
| result.Add(GetAvxLibraryPath(configuration.AvxLevel, prefix, suffix, libraryNamePrefix)); | |||||
| } | } | ||||
| else if (platform != OSPlatform.OSX) // in macos there's absolutely no avx | else if (platform != OSPlatform.OSX) // in macos there's absolutely no avx | ||||
| { | { | ||||
| if (configuration.AvxLevel >= NativeLibraryConfig.AvxLevel.Avx512) | if (configuration.AvxLevel >= NativeLibraryConfig.AvxLevel.Avx512) | ||||
| result.Add(GetAvxLibraryPath(NativeLibraryConfig.AvxLevel.Avx512, prefix, suffix)); | |||||
| result.Add(GetAvxLibraryPath(NativeLibraryConfig.AvxLevel.Avx512, prefix, suffix, libraryNamePrefix)); | |||||
| if (configuration.AvxLevel >= NativeLibraryConfig.AvxLevel.Avx2) | if (configuration.AvxLevel >= NativeLibraryConfig.AvxLevel.Avx2) | ||||
| result.Add(GetAvxLibraryPath(NativeLibraryConfig.AvxLevel.Avx2, prefix, suffix)); | |||||
| result.Add(GetAvxLibraryPath(NativeLibraryConfig.AvxLevel.Avx2, prefix, suffix, libraryNamePrefix)); | |||||
| if (configuration.AvxLevel >= NativeLibraryConfig.AvxLevel.Avx) | if (configuration.AvxLevel >= NativeLibraryConfig.AvxLevel.Avx) | ||||
| result.Add(GetAvxLibraryPath(NativeLibraryConfig.AvxLevel.Avx, prefix, suffix)); | |||||
| result.Add(GetAvxLibraryPath(NativeLibraryConfig.AvxLevel.Avx, prefix, suffix, libraryNamePrefix)); | |||||
| result.Add(GetAvxLibraryPath(NativeLibraryConfig.AvxLevel.None, prefix, suffix)); | |||||
| result.Add(GetAvxLibraryPath(NativeLibraryConfig.AvxLevel.None, prefix, suffix, libraryNamePrefix)); | |||||
| } | } | ||||
| if (platform == OSPlatform.OSX) | if (platform == OSPlatform.OSX) | ||||
| { | { | ||||
| result.Add($"{prefix}{libraryName}{suffix}"); | |||||
| result.Add($"{prefix}{libraryNamePrefix}{libraryName}{suffix}"); | |||||
| } | } | ||||
| return result; | return result; | ||||