Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR updates whisper.cpp and adds metal support.
This PR should not be merged to master, however I'm opening it regardless since it provides an example others might find useful in getting whisper.cpp working on Metal. In my experience, combining the
WHISPER_USE_COREML
andGGML_USE_METAL
flags results in a significant performance improvement.How it works
It relies heavily on symlinks to ensure the correct files are compiled with the correct flags. It was necessary to create two targets:
This is because
ggml-metal.m
must be compiled with the-fno-objc-arc
flag, butwhisper-encoder-impl.m
will not compile with this flag.Therefore:
../whisper_cpp_metal/ggml-metal.h
ggml-metal.m
as well as thewhisper.h
overall header file.Issues
Because of the way SPM works, it isn't capable of including the
ggml-metal.metal
file as a resource that can be easily accessed and therefore still requires you to manually include it in your Xcode project in the "Copy Files" Build Phase. If anyone can find a way to get this working automatically, please contribute or let me know!You can get the metal file from here.
Another reason this would probably have to retain in PR state or another branch at least is that SPM has no way of dynamically defining what
cSettings
flags should be used. Ideally the user of the package would be able to somehow define that they want to use Metal, and only if they do should theDGGML_USE_METAL
flag be added.For now though, this is here for anyone that wants to play around with it.