diff --git a/dnn/dump_data.c b/dnn/dump_data.c index cf17d693..713c529e 100644 --- a/dnn/dump_data.c +++ b/dnn/dump_data.c @@ -182,8 +182,8 @@ int main(int argc, char **argv) { int ret; unsigned char buf[8]; float features[4][NB_TOTAL_FEATURES]; - //int c0_id, main_pitch, modulation, corr_id, vq_end[3], vq_mid, interp_id; - //ret = fscanf(f1, "%d %d %d %d %d %d %d %d %d\n", &c0_id, &main_pitch, &modulation, &corr_id, &vq_end[0], &vq_end[1], &vq_end[2], &vq_mid, &interp_id); + /*int c0_id, main_pitch, modulation, corr_id, vq_end[3], vq_mid, interp_id;*/ + /*ret = fscanf(f1, "%d %d %d %d %d %d %d %d %d\n", &c0_id, &main_pitch, &modulation, &corr_id, &vq_end[0], &vq_end[1], &vq_end[2], &vq_mid, &interp_id);*/ ret = fread(buf, 1, 8, f1); if (ret != 8) break; decode_packet(features, vq_mem, buf); @@ -279,7 +279,7 @@ int main(int argc, char **argv) { } st->pcount = 0; } - //if (fpcm) fwrite(pcm, sizeof(short), FRAME_SIZE, fpcm); + /*if (fpcm) fwrite(pcm, sizeof(short), FRAME_SIZE, fpcm);*/ for (i=0;i= 4096) { vq_mid -= 4096; sign = -1; diff --git a/dnn/lpcnet_enc.c b/dnn/lpcnet_enc.c index 34a85a24..f13476ee 100644 --- a/dnn/lpcnet_enc.c +++ b/dnn/lpcnet_enc.c @@ -43,9 +43,6 @@ #include "lpcnet.h" -//#define NB_FEATURES (NB_BANDS+2+LPC_ORDER) - - #define SURVIVORS 5 @@ -158,10 +155,10 @@ int quantize_3stage_mbest(float *x, int entry[3]) index2[m][1] = curr_index[m]; glob_dist[m] = curr_dist[m]; } - //printf("%f ", glob_dist[0]); + /*printf("%f ", glob_dist[0]);*/ } else if (curr_dist[0] < glob_dist[SURVIVORS-1]) { - m=0; int pos; + m=0; for (pos=0;pos= FORBIDDEN_INTERP); } @@ -531,7 +528,7 @@ void compute_frame_features(LPCNetEncState *st, const float *in) { st->pitch_mem[0] = aligned_in[i]; st->exc_buf[PITCH_MAX_PERIOD+i] = sum + .7*st->pitch_filt; st->pitch_filt = sum; - //printf("%f\n", st->exc_buf[PITCH_MAX_PERIOD+i]); + /*printf("%f\n", st->exc_buf[PITCH_MAX_PERIOD+i]);*/ } /* Cross-correlation on half-frames. */ for (sub=0;sub<2;sub++) { @@ -539,7 +536,7 @@ void compute_frame_features(LPCNetEncState *st, const float *in) { celt_pitch_xcorr(&st->exc_buf[PITCH_MAX_PERIOD+off], st->exc_buf+off, xcorr, FRAME_SIZE/2, PITCH_MAX_PERIOD); ener0 = celt_inner_prod(&st->exc_buf[PITCH_MAX_PERIOD+off], &st->exc_buf[PITCH_MAX_PERIOD+off], FRAME_SIZE/2); st->frame_weight[2+2*st->pcount+sub] = ener0; - //printf("%f\n", st->frame_weight[2+2*st->pcount+sub]); + /*printf("%f\n", st->frame_weight[2+2*st->pcount+sub]);*/ for (i=0;iexc_buf[i+off], &st->exc_buf[i+off], FRAME_SIZE/2)); st->xc[2+2*st->pcount+sub][i] = 2*xcorr[i] / ener; @@ -619,8 +616,8 @@ void process_superframe(LPCNetEncState *st, unsigned char *buf, FILE *ffeat, int } /* Renormalize. */ for (i=0;ipitch_max_path[1][i] -= max_path_all; - //for (i=0;ipitch_max_path[1][i]); - //printf("\n"); + /*for (i=0;ipitch_max_path[1][i]); + printf("\n");*/ RNN_COPY(&st->pitch_max_path[0][0], &st->pitch_max_path[1][0], PITCH_MAX_PERIOD); st->pitch_max_path_all = max_path_all; st->best_i = best_i; @@ -636,9 +633,9 @@ void process_superframe(LPCNetEncState *st, unsigned char *buf, FILE *ffeat, int frame_corr /= 8; if (quantize && frame_corr < 0) frame_corr = 0; for (sub=0;sub<8;sub++) { - //printf("%d %f\n", best[2+sub], frame_corr); + /*printf("%d %f\n", best[2+sub], frame_corr);*/ } - //printf("\n"); + /*printf("\n");*/ for (sub=2;sub<10;sub++) { w = st->frame_weight[sub]; sw += w; @@ -663,7 +660,7 @@ void process_superframe(LPCNetEncState *st, unsigned char *buf, FILE *ffeat, int corr_id = (int)floor(frame_corr/.075f); if (quantize) frame_corr = 0.0375f + .075f*corr_id; } - //best_b = (sxx*sy - sx*sxy)/(sw*sxx - sx*sx); + /*best_b = (sxx*sy - sx*sxy)/(sw*sxx - sx*sx);*/ best_b = (sy - best_a*sx)/sw; /* Quantizing the pitch as "main" pitch + slope. */ center_pitch = best_b+5.5*best_a; @@ -671,9 +668,9 @@ void process_superframe(LPCNetEncState *st, unsigned char *buf, FILE *ffeat, int main_pitch = IMAX(0, IMIN(63, main_pitch)); modulation = (int)floor(.5 + 16*7*best_a/center_pitch); modulation = IMAX(-3, IMIN(3, modulation)); - //printf("%d %d\n", main_pitch, modulation); - //printf("%f %f\n", best_a/center_pitch, best_corr); - //for (sub=2;sub<10;sub++) printf("%f %d %f\n", best_b + sub*best_a, best[sub], best_corr); + /*printf("%d %d\n", main_pitch, modulation);*/ + /*printf("%f %f\n", best_a/center_pitch, best_corr);*/ + /*for (sub=2;sub<10;sub++) printf("%f %d %f\n", best_b + sub*best_a, best[sub], best_corr);*/ for (sub=0;sub<4;sub++) { if (quantize) { float p = pow(2.f, main_pitch/21.)*PITCH_MIN_PERIOD; @@ -685,13 +682,13 @@ void process_superframe(LPCNetEncState *st, unsigned char *buf, FILE *ffeat, int st->features[sub][NB_BANDS] = .01*(IMAX(66, IMIN(510, best[2+2*sub]+best[2+2*sub+1]))-200); st->features[sub][NB_BANDS + 1] = frame_corr-.5; } - //printf("%f %d %f\n", st->features[sub][NB_BANDS], best[2+2*sub], frame_corr); + /*printf("%f %d %f\n", st->features[sub][NB_BANDS], best[2+2*sub], frame_corr);*/ } - //printf("%d %f %f %f\n", best_period, best_a, best_b, best_corr); + /*printf("%d %f %f %f\n", best_period, best_a, best_b, best_corr);*/ RNN_COPY(&st->xc[0][0], &st->xc[8][0], PITCH_MAX_PERIOD); RNN_COPY(&st->xc[1][0], &st->xc[9][0], PITCH_MAX_PERIOD); if (quantize) { - //printf("%f\n", st->features[3][0]); + /*printf("%f\n", st->features[3][0]);*/ c0_id = (int)floor(.5 + st->features[3][0]*4); c0_id = IMAX(-64, IMIN(63, c0_id)); st->features[3][0] = c0_id/4.; @@ -705,11 +702,11 @@ void process_superframe(LPCNetEncState *st, unsigned char *buf, FILE *ffeat, int lpc_from_cepstrum(st->lpc, st->features[sub]); for (i=0;ifeatures[sub][NB_BANDS+2+i] = st->lpc[i]; } - //printf("\n"); + /*printf("\n");*/ RNN_COPY(st->vq_mem, &st->features[3][0], NB_BANDS); if (encode) { packer bits; - //fprintf(stdout, "%d %d %d %d %d %d %d %d %d\n", c0_id+64, main_pitch, voiced ? modulation+4 : 0, corr_id, vq_end[0], vq_end[1], vq_end[2], vq_mid, interp_id); + /*fprintf(stdout, "%d %d %d %d %d %d %d %d %d\n", c0_id+64, main_pitch, voiced ? modulation+4 : 0, corr_id, vq_end[0], vq_end[1], vq_end[2], vq_mid, interp_id);*/ bits_packer_init(&bits, buf, 8); bits_pack(&bits, c0_id+64, 7); bits_pack(&bits, main_pitch, 6); @@ -765,8 +762,8 @@ void process_multi_frame(LPCNetEncState *st, FILE *ffeat) { } /* Renormalize. */ for (i=0;ipitch_max_path[1][i] -= max_path_all; - //for (i=0;ipitch_max_path[1][i]); - //printf("\n"); + /*for (i=0;ipitch_max_path[1][i]); + printf("\n");*/ RNN_COPY(&st->pitch_max_path[0][0], &st->pitch_max_path[1][0], PITCH_MAX_PERIOD); st->pitch_max_path_all = max_path_all; st->best_i = best_i; @@ -783,12 +780,12 @@ void process_multi_frame(LPCNetEncState *st, FILE *ffeat) { for (sub=0;sub<4;sub++) { st->features[sub][NB_BANDS] = .01*(IMAX(66, IMIN(510, best[2+2*sub]+best[2+2*sub+1]))-200); st->features[sub][NB_BANDS + 1] = frame_corr-.5; - //printf("%f %d %f\n", st->features[sub][NB_BANDS], best[2+2*sub], frame_corr); + /*printf("%f %d %f\n", st->features[sub][NB_BANDS], best[2+2*sub], frame_corr);*/ } - //printf("%d %f %f %f\n", best_period, best_a, best_b, best_corr); + /*printf("%d %f %f %f\n", best_period, best_a, best_b, best_corr);*/ RNN_COPY(&st->xc[0][0], &st->xc[8][0], PITCH_MAX_PERIOD); RNN_COPY(&st->xc[1][0], &st->xc[9][0], PITCH_MAX_PERIOD); - //printf("\n"); + /*printf("\n");*/ RNN_COPY(st->vq_mem, &st->features[3][0], NB_BANDS); if (ffeat) { for (i=0;i<4;i++) { @@ -833,8 +830,8 @@ void process_single_frame(LPCNetEncState *st, FILE *ffeat) { } /* Renormalize. */ for (i=0;ipitch_max_path[1][i] -= max_path_all; - //for (i=0;ipitch_max_path[1][i]); - //printf("\n"); + /*for (i=0;ipitch_max_path[1][i]); + printf("\n");*/ RNN_COPY(&st->pitch_max_path[0][0], &st->pitch_max_path[1][0], PITCH_MAX_PERIOD); st->pitch_max_path_all = max_path_all; st->best_i = best_i; diff --git a/dnn/lpcnet_plc.c b/dnn/lpcnet_plc.c index f7525f3f..1c8d491d 100644 --- a/dnn/lpcnet_plc.c +++ b/dnn/lpcnet_plc.c @@ -57,7 +57,7 @@ LPCNET_EXPORT int lpcnet_plc_update(LPCNetPLCState *st, short *pcm) { short output[FRAME_SIZE]; st->enc.pcount = 0; if (st->skip_analysis) { - //fprintf(stderr, "skip update\n"); + /*fprintf(stderr, "skip update\n");*/ if (st->blend) { short tmp[FRAME_SIZE-TRAINING_OFFSET]; lpcnet_synthesize_tail_impl(&st->lpcnet, tmp, FRAME_SIZE-TRAINING_OFFSET, 0); @@ -73,10 +73,10 @@ LPCNET_EXPORT int lpcnet_plc_update(LPCNetPLCState *st, short *pcm) { RNN_COPY(&st->pcm[st->pcm_fill], pcm, FRAME_SIZE); st->pcm_fill += FRAME_SIZE; } - //fprintf(stderr, "fill at %d\n", st->pcm_fill); + /*fprintf(stderr, "fill at %d\n", st->pcm_fill);*/ } /* Update state. */ - //fprintf(stderr, "update state\n"); + /*fprintf(stderr, "update state\n");*/ for (i=0;ienc.mem_preemph, x, PREEMPHASIS, FRAME_SIZE); compute_frame_features(&st->enc, x); @@ -105,7 +105,7 @@ LPCNET_EXPORT int lpcnet_plc_conceal(LPCNetPLCState *st, short *pcm) { /* If we concealed the previous frame, finish synthesizing the rest of the samples. */ /* FIXME: Copy/predict features. */ while (st->pcm_fill > 0) { - //fprintf(stderr, "update state for PLC %d\n", st->pcm_fill); + /*fprintf(stderr, "update state for PLC %d\n", st->pcm_fill);*/ int update_count; update_count = IMIN(st->pcm_fill, FRAME_SIZE); RNN_COPY(output, &st->pcm[0], update_count); diff --git a/dnn/nnet.c b/dnn/nnet.c index 7a74c00b..31472033 100644 --- a/dnn/nnet.c +++ b/dnn/nnet.c @@ -144,6 +144,8 @@ void compute_mdense(const MDenseLayer *layer, float *output, const float *input) int sample_mdense(const MDenseLayer *layer, const float *input, const float *sampling_logit_table, kiss99_ctx *rng) { int b, j, N, M, C, stride; + int val=0; + float thresholds[8]; M = layer->nb_inputs; N = layer->nb_neurons; C = layer->nb_channels; @@ -151,8 +153,6 @@ int sample_mdense(const MDenseLayer *layer, const float *input, const float *sam stride = M*C; celt_assert(N <= DUAL_FC_OUT_SIZE); - int val=0; - float thresholds[8]; /* Computing all the random thresholds in advance. These thresholds are directly based on the logit to avoid computing the sigmoid.*/ @@ -181,7 +181,7 @@ int sample_mdense(const MDenseLayer *layer, const float *input, const float *sam sum1 = layer->factor[i]*tanh_approx(sum1); sum2 = layer->factor[N + i]*tanh_approx(sum2); sum1 += sum2; - //sum1 = 1.f/(1 + exp(-sum1)); + /*sum1 = 1.f/(1 + exp(-sum1));*/ #if 1 /* Sample the decision based on the logit. */ bit = thresholds[b] < sum1; #else diff --git a/dnn/pitch.c b/dnn/pitch.c index e3a73b38..8abbdef5 100644 --- a/dnn/pitch.c +++ b/dnn/pitch.c @@ -37,9 +37,6 @@ #include "pitch.h" #include "common.h" -//#include "modes.h" -//#include "stack_alloc.h" -//#include "mathops.h" #include "celt_lpc.h" #include "math.h" diff --git a/dnn/pitch.h b/dnn/pitch.h index 9126132c..2784d537 100644 --- a/dnn/pitch.h +++ b/dnn/pitch.h @@ -34,8 +34,6 @@ #ifndef PITCH_H #define PITCH_H -//#include "modes.h" -//#include "cpu_support.h" #include "arch.h" /* OPT: This is the kernel you really want to optimize. It gets used a lot diff --git a/dnn/vec.h b/dnn/vec.h index ca635ddc..d1f82b54 100644 --- a/dnn/vec.h +++ b/dnn/vec.h @@ -47,7 +47,7 @@ #ifndef DISABLE_DOT_PROD #define DOT_PROD -//#define USE_SU_BIAS +/*#define USE_SU_BIAS*/ #endif #ifdef DOT_PROD diff --git a/dnn/vec_avx.h b/dnn/vec_avx.h index 0183ea38..798165a7 100644 --- a/dnn/vec_avx.h +++ b/dnn/vec_avx.h @@ -320,15 +320,12 @@ static inline void vector_ps_to_epi8(unsigned char *x, const float *_x, int len) __m256 xf; __m256i xi; xf = _mm256_loadu_ps(&_x[i]); - //xf = _mm256_mul_ps(xf, const127); - //xf = _mm256_add_ps(xf, const127); xf = _mm256_fmadd_ps(xf, const127, const127); xi = _mm256_cvtps_epi32(xf); xi = _mm256_packus_epi32(xi, _mm256_setzero_si256()); xi = _mm256_permute4x64_epi64(xi, 0xD8); xi = _mm256_packus_epi16(xi, _mm256_setzero_si256()); xi = _mm256_permutevar8x32_epi32(xi, _mm256_setr_epi32(0,1, 0,0, 0,0, 0,0)); - //xi = _mm256_permute4x64_epi64(xi, 0x); _mm256_storeu_si256 ((__m256i *)&x[i], xi); } } @@ -618,7 +615,7 @@ static inline void sgemv_accum16(float *out, const float *weights, int rows, int int i, j; for (i=0;i