Skip to content
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

Embed Metal library source into compiled binary #1842

Merged
merged 4 commits into from
Feb 11, 2024

Conversation

didzis
Copy link
Contributor

@didzis didzis commented Feb 7, 2024

This PR adds option to embed ggml-metal.metal file directly into exectuable.

enable by setting WHISPER_EMBED_METAL_LIBRARY
Copy link
Owner

@ggerganov ggerganov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, that's a neat trick!

Is there a way to avoid the extra file ggml-metal-embed.s?
For example, could it be part of ggml-metal.m just surrounded by a specific define like GGML_METAL_BUILD_ASM

#ifndef GGML_METAL_BUILD_ASM
... ggml-metal.m source ...
#else
... ggml-metal-embed.s ...
#endif

Or something similar - just looking for ways to avoid the extra file

CMakeLists.txt Outdated
@@ -68,6 +68,7 @@ if (APPLE)
option(WHISPER_METAL_NDEBUG "whisper: disable Metal debugging" OFF)
option(WHISPER_COREML "whisper: enable Core ML framework" OFF)
option(WHISPER_COREML_ALLOW_FALLBACK "whisper: allow non-CoreML fallback" OFF)
option(WHISPER_EMBED_METAL_LIBRARY "whisper: embed Metal library" OFF)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to WHISPER_METAL_EMBED_LIBRARY

Copy link
Contributor Author

@didzis didzis Feb 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated also the preprocessor directive name

@didzis
Copy link
Contributor Author

didzis commented Feb 10, 2024

It looks like it is not possible to embed this approach into Objective-C source, however if the aim is to avoid having another file in the source tree, I updated the build process so that the assembly is autogenerated during the build phase.

@ggerganov ggerganov merged commit 163e74b into ggerganov:master Feb 11, 2024
39 checks passed
jiahansu pushed a commit to WiseSync/whisper.cpp that referenced this pull request Apr 17, 2024
* ggml : embed Metal library source (ggml-metal.metal) into binary

enable by setting WHISPER_EMBED_METAL_LIBRARY

* rename the build option

* rename the preprocessor directive

* generate Metal library embedding assembly on-fly during build process
viktor-silakov pushed a commit to viktor-silakov/whisper_node_mic.cpp that referenced this pull request May 11, 2024
* ggml : embed Metal library source (ggml-metal.metal) into binary

enable by setting WHISPER_EMBED_METAL_LIBRARY

* rename the build option

* rename the preprocessor directive

* generate Metal library embedding assembly on-fly during build process
jiahansu pushed a commit to WiseSync/whisper.cpp that referenced this pull request May 15, 2024
* ggml : embed Metal library source (ggml-metal.metal) into binary

enable by setting WHISPER_EMBED_METAL_LIBRARY

* rename the build option

* rename the preprocessor directive

* generate Metal library embedding assembly on-fly during build process
iThalay pushed a commit to iThalay/whisper.cpp that referenced this pull request Sep 23, 2024
* ggml : embed Metal library source (ggml-metal.metal) into binary

enable by setting WHISPER_EMBED_METAL_LIBRARY

* rename the build option

* rename the preprocessor directive

* generate Metal library embedding assembly on-fly during build process
iThalay pushed a commit to iThalay/whisper.cpp that referenced this pull request Sep 23, 2024
* ggml : embed Metal library source (ggml-metal.metal) into binary

enable by setting WHISPER_EMBED_METAL_LIBRARY

* rename the build option

* rename the preprocessor directive

* generate Metal library embedding assembly on-fly during build process
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants