Skip to content

Commit cba7e37

Browse files
committed
fix: expf overflow on avx2.
1 parent a586ec7 commit cba7e37

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/nn/nn-cpu-ops.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ static inline float horizontalMax_avx2(__m256 v) {
8484
}
8585

8686
static inline __m256 expf_avx2(__m256 x) {
87+
x = _mm256_max_ps(x, _mm256_set1_ps(-88.0f));
88+
8789
const __m256 log2e = _mm256_set1_ps(1.4426950408889634f);
8890
const __m256 c0 = _mm256_set1_ps(1.0f);
8991
const __m256 c1 = _mm256_set1_ps(0.6931471805599453f);

0 commit comments

Comments
 (0)