Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.xiph.org/xiph/opus.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@amazon.com>2023-07-28 02:51:43 +0300
committerJean-Marc Valin <jmvalin@amazon.com>2023-07-28 03:02:26 +0300
commit98bd589109db00985f6adf9e36586533526d365d (patch)
tree1c292c2e865d0109cea5f455f868f892be25f953
parenteb72d29a15a24cc1b68f66161293299cf06f0cc3 (diff)
Make RDOVAE encoder use LinearLayer directly
-rwxr-xr-xautogen.sh2
-rw-r--r--dnn/download_model.bat2
-rwxr-xr-xdnn/download_model.sh4
-rw-r--r--dnn/dred_rdovae_enc.c23
-rw-r--r--dnn/nnet.h2
-rw-r--r--dnn/write_lpcnet_weights.c2
-rw-r--r--silk/dred_encoder.c2
7 files changed, 16 insertions, 21 deletions
diff --git a/autogen.sh b/autogen.sh
index f2f3841d..2d8e86cd 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -9,7 +9,7 @@ set -e
srcdir=`dirname $0`
test -n "$srcdir" && cd "$srcdir"
-(cd dnn; ./download_model.sh 2ddc476)
+(cd dnn; ./download_model.sh eb72d29)
echo "Updating build configuration files, please wait...."
diff --git a/dnn/download_model.bat b/dnn/download_model.bat
index ba16f0f0..32d03ff8 100644
--- a/dnn/download_model.bat
+++ b/dnn/download_model.bat
@@ -7,5 +7,3 @@ if not exist %model% (
)
tar -xvzf %model%
-move .\src\*.c .
-move .\src\*.h .
diff --git a/dnn/download_model.sh b/dnn/download_model.sh
index b5fbf000..aceeee9d 100755
--- a/dnn/download_model.sh
+++ b/dnn/download_model.sh
@@ -8,6 +8,4 @@ if [ ! -f $model ]; then
wget https://media.xiph.org/lpcnet/data/$model
fi
tar xvof $model
-touch src/nnet_data.[ch]
-touch src/plc_data.[ch]
-mv src/*.[ch] .
+touch *_data.[ch]
diff --git a/dnn/dred_rdovae_enc.c b/dnn/dred_rdovae_enc.c
index d1bee1ee..9361af17 100644
--- a/dnn/dred_rdovae_enc.c
+++ b/dnn/dred_rdovae_enc.c
@@ -46,50 +46,49 @@ void dred_rdovae_encode_dframe(
float buffer[ENC_DENSE1_OUT_SIZE + ENC_DENSE2_OUT_SIZE + ENC_DENSE3_OUT_SIZE + ENC_DENSE4_OUT_SIZE + ENC_DENSE5_OUT_SIZE + ENC_DENSE6_OUT_SIZE + ENC_DENSE7_OUT_SIZE + ENC_DENSE8_OUT_SIZE + GDENSE1_OUT_SIZE];
int output_index = 0;
int input_index = 0;
- float zero_vector[1024] = {0};
/* run encoder stack and concatenate output in buffer*/
- _lpcnet_compute_dense(&model->enc_dense1, &buffer[output_index], input);
+ compute_generic_dense(&model->enc_dense1, &buffer[output_index], input, ACTIVATION_TANH);
input_index = output_index;
output_index += ENC_DENSE1_OUT_SIZE;
- compute_gruB(&model->enc_dense2, zero_vector, enc_state->dense2_state, &buffer[input_index]);
+ compute_generic_gru(&model->enc_dense2_input, &model->enc_dense2_recurrent, enc_state->dense2_state, &buffer[input_index]);
OPUS_COPY(&buffer[output_index], enc_state->dense2_state, ENC_DENSE2_OUT_SIZE);
input_index = output_index;
output_index += ENC_DENSE2_OUT_SIZE;
- _lpcnet_compute_dense(&model->enc_dense3, &buffer[output_index], &buffer[input_index]);
+ compute_generic_dense(&model->enc_dense3, &buffer[output_index], &buffer[input_index], ACTIVATION_TANH);
input_index = output_index;
output_index += ENC_DENSE3_OUT_SIZE;
- compute_gruB(&model->enc_dense4, zero_vector, enc_state->dense4_state, &buffer[input_index]);
+ compute_generic_gru(&model->enc_dense4_input, &model->enc_dense4_recurrent, enc_state->dense4_state, &buffer[input_index]);
OPUS_COPY(&buffer[output_index], enc_state->dense4_state, ENC_DENSE4_OUT_SIZE);
input_index = output_index;
output_index += ENC_DENSE4_OUT_SIZE;
- _lpcnet_compute_dense(&model->enc_dense5, &buffer[output_index], &buffer[input_index]);
+ compute_generic_dense(&model->enc_dense5, &buffer[output_index], &buffer[input_index], ACTIVATION_TANH);
input_index = output_index;
output_index += ENC_DENSE5_OUT_SIZE;
- compute_gruB(&model->enc_dense6, zero_vector, enc_state->dense6_state, &buffer[input_index]);
+ compute_generic_gru(&model->enc_dense6_input, &model->enc_dense6_recurrent, enc_state->dense6_state, &buffer[input_index]);
OPUS_COPY(&buffer[output_index], enc_state->dense6_state, ENC_DENSE6_OUT_SIZE);
input_index = output_index;
output_index += ENC_DENSE6_OUT_SIZE;
- _lpcnet_compute_dense(&model->enc_dense7, &buffer[output_index], &buffer[input_index]);
+ compute_generic_dense(&model->enc_dense7, &buffer[output_index], &buffer[input_index], ACTIVATION_TANH);
input_index = output_index;
output_index += ENC_DENSE7_OUT_SIZE;
- _lpcnet_compute_dense(&model->enc_dense8, &buffer[output_index], &buffer[input_index]);
+ compute_generic_dense(&model->enc_dense8, &buffer[output_index], &buffer[input_index], ACTIVATION_TANH);
output_index += ENC_DENSE8_OUT_SIZE;
/* compute latents from concatenated input buffer */
- compute_conv1d(&model->bits_dense, latents, enc_state->bits_dense_state, buffer);
+ compute_generic_conv1d(&model->bits_dense, latents, enc_state->bits_dense_state, buffer, BITS_DENSE_IN_SIZE, ACTIVATION_LINEAR);
/* next, calculate initial state */
- _lpcnet_compute_dense(&model->gdense1, &buffer[output_index], buffer);
+ compute_generic_dense(&model->gdense1, &buffer[output_index], buffer, ACTIVATION_TANH);
input_index = output_index;
- _lpcnet_compute_dense(&model->gdense2, initial_state, &buffer[input_index]);
+ compute_generic_dense(&model->gdense2, initial_state, &buffer[input_index], ACTIVATION_TANH);
}
diff --git a/dnn/nnet.h b/dnn/nnet.h
index 71c91ca3..0e7cd6dc 100644
--- a/dnn/nnet.h
+++ b/dnn/nnet.h
@@ -161,7 +161,7 @@ int sample_from_pdf(const float *pdf, int N, float exp_boost, float pdf_floor);
extern const WeightArray lpcnet_arrays[];
extern const WeightArray lpcnet_plc_arrays[];
-extern const WeightArray rdovae_enc_arrays[];
+extern const WeightArray rdovaeenc_arrays[];
extern const WeightArray rdovae_dec_arrays[];
int linear_init(LinearLayer *layer, const WeightArray *arrays,
diff --git a/dnn/write_lpcnet_weights.c b/dnn/write_lpcnet_weights.c
index b1760161..aa36db1f 100644
--- a/dnn/write_lpcnet_weights.c
+++ b/dnn/write_lpcnet_weights.c
@@ -72,7 +72,7 @@ int main(void)
FILE *fout = fopen("weights_blob.bin", "w");
write_weights(lpcnet_arrays, fout);
write_weights(lpcnet_plc_arrays, fout);
- write_weights(rdovae_enc_arrays, fout);
+ write_weights(rdovaeenc_arrays, fout);
write_weights(rdovae_dec_arrays, fout);
fclose(fout);
return 0;
diff --git a/silk/dred_encoder.c b/silk/dred_encoder.c
index 89e0f900..5bae39e9 100644
--- a/silk/dred_encoder.c
+++ b/silk/dred_encoder.c
@@ -69,7 +69,7 @@ void dred_encoder_init(DREDEnc* enc, opus_int32 Fs, int channels)
enc->Fs = Fs;
enc->channels = channels;
#ifndef USE_WEIGHTS_FILE
- init_rdovaeenc(&enc->model, rdovae_enc_arrays);
+ init_rdovaeenc(&enc->model, rdovaeenc_arrays);
#endif
dred_encoder_reset(enc);
}