shithub: opus

Download patch

ref: 141830ce5a85c006d0b6df196a7cee839c8d4c3c
parent: 37fbcaee0b550c8141cd5d8a7ff40bfc3b2e9c55
author: Jean-Marc Valin <jmvalin@jmvalin.ca>
date: Sat Nov 24 11:00:30 EST 2018

Fixing includes

--- a/dnn/dump_lpcnet.py
+++ b/dnn/dump_lpcnet.py
@@ -134,15 +134,23 @@
 
 model.load_weights(sys.argv[1])
 
-f = open(sys.argv[2], 'w')
-hf = open(sys.argv[3], 'w')
+if len(sys.argv) > 2:
+    cfile = sys.argv[2];
+    hfile = sys.argv[3];
+else:
+    cfile = 'nnet_data.c'
+    hfile = 'nnet_data.h'
 
 
+f = open(cfile, 'w')
+hf = open(hfile, 'w')
+
+
 f.write('/*This file is automatically generated from a Keras model*/\n\n')
-f.write('#ifdef HAVE_CONFIG_H\n#include "config.h"\n#endif\n\n#include "nnet.h"\n#include "foo.h"\n\n')
+f.write('#ifdef HAVE_CONFIG_H\n#include "config.h"\n#endif\n\n#include "nnet.h"\n#include "{}"\n\n'.format(hfile))
 
 hf.write('/*This file is automatically generated from a Keras model*/\n\n')
-hf.write('#ifndef RNN_DATA_H\n#define RNN_DATA_H\n\n#include "{}"\n\n'.format(sys.argv[3]))
+hf.write('#ifndef RNN_DATA_H\n#define RNN_DATA_H\n\n#include "nnet.h"\n\n')
 
 layer_list = []
 for i, layer in enumerate(model.layers):
--- a/dnn/nnet.c
+++ b/dnn/nnet.c
@@ -36,6 +36,7 @@
 #include "common.h"
 #include "tansig_table.h"
 #include "nnet.h"
+#include "nnet_data.h"
 
 static OPUS_INLINE float tansig_approx(float x)
 {
@@ -136,6 +137,7 @@
    M = layer->nb_inputs;
    N = layer->nb_neurons;
    C = layer->nb_channels;
+   celt_assert(N*C <= MAX_MDENSE_TMP);
    stride = N*C;
    for (i=0;i<N*C;i++)
       tmp[i] = layer->bias[i];
--