Faster NaN-free tanh

This commit is contained in:
Stéphane du Hamel 2024-12-08 18:30:18 +01:00
parent 93bdbc656d
commit d94ff95565

View file

@ -16,6 +16,5 @@ void main() {
if (i >= p.KX) { if (i >= p.KX) {
return; return;
} }
float th = tanh(data_a[i]); data_d[i] = D_TYPE(1. - 2. / (exp(2.*data_a[i]) + 1.));
data_d[i] = D_TYPE(th==th ? th : sign(data_a[i]));
} }