whisper.cpp
whisper.cpp copied to clipboard
Add .clang-format
Here is a first attempt to clang-format as close to the existing format as possible (#332).
I formatted the whisper and ggml files to show what it does. If there's anything here you absolutely won't accept, please let me know and I'll see if I can fix it or find a workaround.
Notes:
- The header files were not consistent with indenting the "extern" block. I chose the no-indent style, but it's easy to change.
- Some table-like declarations in whisper.cpp are almost impossible to format the way they were, so the formatter was turned off for them using
// clang-format off
. - The unusual formatting in the case statement in
whisper_full_default_params
got mangled. We can either change the way this is commented or turn off formatting for that section as well.
As noted, some formatting can be turned off using // clang-format off
but in general I think this should be discouraged.
On second thought, I think .clang-format
is not a good option.
In this project, I use a unique code formatting where sequential lines are vertically aligned and I really like it this way.
I don't think there is a way for .clang-format
to achieve this.
If you mean these:
struct ggml_tensor * ggml_scale(
struct ggml_context * ctx,
struct ggml_tensor * a,
struct ggml_tensor * b);
struct ggml_tensor * ggml_scale(struct ggml_context * ctx, struct ggml_tensor * a, struct ggml_tensor * b);
Indeed at the time I could not figure out how to force that properly. 🤔
It's just that without auto-formatting it makes it more difficult for others to contribute & you will probably have to waste time paying attention to & fixing the formatting for any PRs (especially since the code already isn't self-consistent).