]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commit
ggml : avoid duplicating function calls using MIN/MAX macros (llama/5325)
authorDr. Tom Murphy VII Ph.D <redacted>
Mon, 5 Feb 2024 11:13:57 +0000 (06:13 -0500)
committerGeorgi Gerganov <redacted>
Sat, 10 Feb 2024 07:55:46 +0000 (09:55 +0200)
commit55bcd62a4be5df37429411e8065d5665122996c6
tree943d3f5eb5da8046f81993ad3f374770fe972127
parent0ed762d691cb6a211b7af6496b3ebaa70e1b848a
ggml : avoid duplicating function calls using MIN/MAX macros (llama/5325)

* Avoid duplicating function calls when using MIN/MAX macros.

Since these copy "a" and "b" they ask the compiler to evaluate one of them twice. The compiler doesn't have a problem with removing the duplication in something like MAX(0, x + 2), but in some cases we're calling functions, and those calls just happen twice.
By explicitly evaluating at the expression we get smaller and faster code without duplicate calls. See ggml_rope_yarn_corr_dims in Compiler Explorer:

https://godbolt.org/z/Ee4KMrvKh

Code behaves exactly the same.

* Update ggml.c

---------

Co-authored-by: Georgi Gerganov <redacted>
ggml.c