]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
Vulkan: fix NaN in tanh.comp with AMD proprietary driver on Windows (llama/10723)
authorstduhpf <redacted>
Sun, 8 Dec 2024 18:19:19 +0000 (19:19 +0100)
committerGeorgi Gerganov <redacted>
Wed, 18 Dec 2024 10:52:16 +0000 (12:52 +0200)
* Vulkan: fix NaN in tanh.comp

* Faster NaN-free tanh

ggml/src/ggml-vulkan/vulkan-shaders/tanh.comp

index 74630dc7fef12f690631e01dbb8b892bd6f35760..495f966bdc6e5a556baffd6d3c5d49531ac434e4 100644 (file)
@@ -16,6 +16,5 @@ void main() {
     if (i >= p.KX) {
         return;
     }
-
-    data_d[i] = D_TYPE(tanh(data_a[i]));
+    data_d[i] = D_TYPE(1. - 2. / (exp(2.*data_a[i]) + 1.));
 }