ref: 4598fe540955755c91a432090086d2bdfaab7f03
parent: 290be25b982380552ced642e51e225c0bbe9985a
author: Jean-Marc Valin <jmvalin@amazon.com>
date: Fri Oct 20 08:54:13 EDT 2023
Quantizing pitchdnn and rdovae weights
--- a/autogen.sh
+++ b/autogen.sh
@@ -9,7 +9,7 @@
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...."
--- a/dnn/torch/neural-pitch/export_neuralpitch_weights.py
+++ b/dnn/torch/neural-pitch/export_neuralpitch_weights.py
@@ -59,19 +59,27 @@
"""
)
- 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 @@
("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(
--- 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 @@
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);
--
⑨