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-10-20 19:54:13 +0300
committerJean-Marc Valin <jmvalin@amazon.com>2023-10-20 19:54:13 +0300
commit4598fe540955755c91a432090086d2bdfaab7f03 (patch)
treed9d7f00df2394ac4dd9e5d22cbd1fb6474db1520
parent290be25b982380552ced642e51e225c0bbe9985a (diff)
Quantizing pitchdnn and rdovae weights
-rwxr-xr-xautogen.sh2
-rw-r--r--dnn/torch/neural-pitch/export_neuralpitch_weights.py20
-rw-r--r--dnn/write_lpcnet_weights.c2
3 files changed, 17 insertions, 7 deletions
diff --git a/autogen.sh b/autogen.sh
index 00b24eff..7f83b4b1 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -9,7 +9,7 @@ set -e
srcdir=`dirname $0`
test -n "$srcdir" && cd "$srcdir"
-dnn/download_model.sh 9e76a7b
+dnn/download_model.sh 290be25
echo "Updating build configuration files, please wait...."
diff --git a/dnn/torch/neural-pitch/export_neuralpitch_weights.py b/dnn/torch/neural-pitch/export_neuralpitch_weights.py
index cab8eaeb..82b2d3d9 100644
--- a/dnn/torch/neural-pitch/export_neuralpitch_weights.py
+++ b/dnn/torch/neural-pitch/export_neuralpitch_weights.py
@@ -59,18 +59,26 @@ f"""
"""
)
- layers = [
+ dense_layers = [
('if_upsample.0', "dense_if_upsampler_1"),
('if_upsample.2', "dense_if_upsampler_2"),
- ('conv.1', "conv2d_1"),
- ('conv.4', "conv2d_2"),
- ('conv.7', "conv2d_3"),
('downsample.0', "dense_downsampler"),
("upsample.0", "dense_final_upsampler")
]
- for name, export_name in layers:
+ for name, export_name in dense_layers:
+ layer = model.get_submodule(name)
+ dump_torch_weights(writer, layer, name=export_name, verbose=True, quantize=True, scale=None)
+
+ conv_layers = [
+ ('conv.1', "conv2d_1"),
+ ('conv.4', "conv2d_2"),
+ ('conv.7', "conv2d_3")
+ ]
+
+
+ for name, export_name in conv_layers:
layer = model.get_submodule(name)
dump_torch_weights(writer, layer, name=export_name, verbose=True)
@@ -79,7 +87,7 @@ f"""
("GRU", "gru_1"),
]
- max_rnn_units = max([dump_torch_weights(writer, model.get_submodule(name), export_name, verbose=True, input_sparse=False, quantize=False)
+ max_rnn_units = max([dump_torch_weights(writer, model.get_submodule(name), export_name, verbose=True, input_sparse=False, quantize=True, scale=None, recurrent_scale=None)
for name, export_name in gru_layers])
writer.header.write(
diff --git a/dnn/write_lpcnet_weights.c b/dnn/write_lpcnet_weights.c
index 6b36ad25..395b8d5d 100644
--- a/dnn/write_lpcnet_weights.c
+++ b/dnn/write_lpcnet_weights.c
@@ -40,6 +40,7 @@
#ifdef USE_WEIGHTS_FILE
#undef USE_WEIGHTS_FILE
#endif
+#include "pitchdnn_data.c"
#include "fargan_data.c"
#include "plc_data.c"
#include "dred_rdovae_enc_data.c"
@@ -70,6 +71,7 @@ void write_weights(const WeightArray *list, FILE *fout)
int main(void)
{
FILE *fout = fopen("weights_blob.bin", "w");
+ write_weights(pitchdnn_arrays, fout);
write_weights(fargan_arrays, fout);
write_weights(lpcnet_plc_arrays, fout);
write_weights(rdovaeenc_arrays, fout);