-
Notifications
You must be signed in to change notification settings - Fork 364
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
feat: add detection template for cuda and avx. #268
Conversation
Just merge cuda and avx detection and change layout.
#endif | ||
?? TryLoad("avx2/libllama.so", System.Runtime.Intrinsics.X86.Avx2.IsSupported) | ||
?? TryLoad("avx/libllama.so", System.Runtime.Intrinsics.X86.Avx.IsSupported) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AVX/AVX2/AVX512 detection should already be handled by this
// Try to load a preferred library, based on CPU feature detection | ||
TryLoadLibrary(); | ||
#if NET6_0_OR_GREATER | ||
NativeLibrary.SetDllImportResolver(typeof(NativeApi).Assembly, LLamaImportResolver); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I deliberately avoided using NativeLibrary.SetDllImportResolver
when I originally set this up, since it overwrites global configuration that may already be in use by the application.
The intention when I originally introduced this was that new dependencies could easily be added (in order of preference, most preferred first) something like this: return TryLoad("magic/libllama.dll", IsMagicSupported())
?? TryLoad("unicorns/libllama.dll", IsUnicornsSupported())
?? TryLoad("rainbows/libllama.dll", IsRainbowsSupported())
?? etc... i.e. any new platform can simply be chained in, so long as you can write a boolean method that prechecks if that particular thing is supported. I deliberately avoided using |
Just for review, please don't merge it.