ref: c7ba313a674afafcb4963a992e185fcd43b247a8
parent: 237245f815fbdf402d75d239fecf19d70fe1956e
author: Jean-Marc Valin <jmvalin@amazon.com>
date: Fri Jun 18 13:39:35 EDT 2021
Adding extra constraint to avoid saturation for SSE/AVX2 When implementing using SSSE3 or AVX2, our dot products can saturate if two adjacent weights sum to more than 127.
--- a/dnn/training_tf2/lpcnet.py
+++ b/dnn/training_tf2/lpcnet.py
@@ -131,7 +131,10 @@
self.c = c
def __call__(self, p):
- return K.clip(p, -self.c, self.c)
+ # Ensure that abs of adjacent weights don't sum to more than 127. Otherwise there's a risk of
+ # saturation when implementing dot products with SSSE3 or AVX2.
+ return self.c*p/tf.maximum(self.c, tf.repeat(tf.abs(p[:, 1::2])+tf.abs(p[:, 0::2]), 2, axis=1))
+ #return K.clip(p, -self.c, self.c)
def get_config(self):
return {'name': self.__class__.__name__,
--
⑨