mirror of
https://github.com/xiph/opus.git
synced 2025-05-28 22:29:14 +00:00
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.
This commit is contained in:
parent
237245f815
commit
c7ba313a67
1 changed files with 4 additions and 1 deletions
|
@ -131,7 +131,10 @@ class WeightClip(Constraint):
|
||||||
self.c = c
|
self.c = c
|
||||||
|
|
||||||
def __call__(self, p):
|
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):
|
def get_config(self):
|
||||||
return {'name': self.__class__.__name__,
|
return {'name': self.__class__.__name__,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue