From 7122abde5914922c1b8ce3cdd76f854e02af5bb1 Mon Sep 17 00:00:00 2001 From: xnorpx <xnorpx@outlook.com> Date: Mon, 22 May 2023 18:48:36 -0700 Subject: [PATCH] Rename celt_exp to lpcnet_exp Depending on what defines are set there is collisions with the ones in Opus. To avoid these errors we rename the exp functions and macros. Signed-off-by: Jean-Marc Valin <jmvalin@amazon.com> --- dnn/test_vec.c | 4 ++-- dnn/vec.h | 6 +++--- dnn/vec_avx.h | 4 ++-- dnn/vec_neon.h | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/dnn/test_vec.c b/dnn/test_vec.c index 09b51e764..1fdc7cb40 100644 --- a/dnn/test_vec.c +++ b/dnn/test_vec.c @@ -10,7 +10,7 @@ // we need to call two versions of each functions that have the same // name, so use #defines to temp rename them -#define celt_exp2 celt_exp2_fast +#define lpcnet_exp2 lpcnet_exp2_fast #define tansig_approx tansig_approx_fast #define sigmoid_approx sigmoid_approx_fast #define softmax softmax_fast @@ -34,7 +34,7 @@ const char simd[]="none"; #endif -#undef celt_exp2 +#undef lpcnet_exp2 #undef tansig_approx #undef sigmoid_approx #undef softmax diff --git a/dnn/vec.h b/dnn/vec.h index d24dd8b6e..c7f2e6959 100644 --- a/dnn/vec.h +++ b/dnn/vec.h @@ -59,7 +59,7 @@ typedef float qweight; /* No AVX2/FMA support */ #ifndef LPCNET_TEST -static inline float celt_exp2(float x) +static inline float lpcnet_exp2(float x) { int integer; float frac; @@ -77,7 +77,7 @@ static inline float celt_exp2(float x) res.i = (res.i + (integer<<23)) & 0x7fffffff; return res.f; } -#define celt_exp(x) celt_exp2((x)*1.44269504f) +#define lpcnet_exp(x) lpcnet_exp2((x)*1.44269504f) static inline float tanh_approx(float x) { @@ -107,7 +107,7 @@ static inline void softmax(float *y, const float *x, int N) { int i; for (i=0;i<N;i++) - y[i] = celt_exp(x[i]); + y[i] = lpcnet_exp(x[i]); } static inline void vec_tanh(float *y, const float *x, int N) diff --git a/dnn/vec_avx.h b/dnn/vec_avx.h index 0c6874a55..733cf6a9b 100644 --- a/dnn/vec_avx.h +++ b/dnn/vec_avx.h @@ -524,7 +524,7 @@ static inline float sigmoid_approx(float x) #endif -static inline float celt_exp(float x) +static inline float lpcnet_exp(float x) { float out[8]; __m256 X, Y; @@ -545,7 +545,7 @@ static inline void softmax(float *y, const float *x, int N) _mm256_storeu_ps(&y[i], Y); } for (;i<N;i++) - y[i] = celt_exp(x[i]); + y[i] = lpcnet_exp(x[i]); } #ifdef __AVX__ diff --git a/dnn/vec_neon.h b/dnn/vec_neon.h index d0a876780..f3a14cc5f 100644 --- a/dnn/vec_neon.h +++ b/dnn/vec_neon.h @@ -110,7 +110,7 @@ static inline float32x4_t sigmoid4_approx(float32x4_t X) return vmaxq_f32(min_out, vminq_f32(max_out, num)); } -static inline float celt_exp(float x) +static inline float lpcnet_exp(float x) { float out[4]; float32x4_t X, Y; @@ -151,7 +151,7 @@ static inline void softmax(float *y, const float *x, int N) vst1q_f32(&y[i], Y); } for (;i<N;i++) - y[i] = celt_exp(x[i]); + y[i] = lpcnet_exp(x[i]); } static inline void vec_tanh(float *y, const float *x, int N) @@ -167,7 +167,7 @@ static inline void vec_tanh(float *y, const float *x, int N) for (;i<N;i++) { float ex2; - ex2 = celt_exp(2*x[i]); + ex2 = lpcnet_exp(2*x[i]); y[i] = (ex2-1)/(ex2+1); } } @@ -185,7 +185,7 @@ static inline void vec_sigmoid(float *y, const float *x, int N) for (;i<N;i++) { float ex; - ex = celt_exp(x[i]); + ex = lpcnet_exp(x[i]); y[i] = (ex)/(ex+1); } } -- GitLab