MLBEDSW-3153: Fix overflow in sigmoid LUT
Overflow could occur in the calculation of the LUT table for sigmoid,
for big negative inputs.
Change-Id: I62a33c68de03e9a7a7e4fe2cbd5835c384dc3643
Signed-off-by: Louis Verhaard <louis.verhaard@arm.com>
diff --git a/ethosu/vela/numeric_util.py b/ethosu/vela/numeric_util.py
index 3d26444..4ebef8e 100644
--- a/ethosu/vela/numeric_util.py
+++ b/ethosu/vela/numeric_util.py
@@ -77,17 +77,13 @@
return y
-def sigmoid(x):
- return 1 / (1 + math.exp(-x))
-
-
def clamp_sigmoid(x):
if x <= -8:
y = 0.0
elif x >= 8:
y = 1.0
else:
- y = sigmoid(x)
+ y = 1 / (1 + math.exp(-x))
return y