diff options
author | Louis Verhaard <louis.verhaard@arm.com> | 2020-09-25 08:30:44 +0200 |
---|---|---|
committer | patrik.gustavsson <patrik.gustavsson@arm.com> | 2020-09-29 07:38:13 +0000 |
commit | f03bad31c194d1a24ce808223f1b00310a7325e2 (patch) | |
tree | 3e24836d8319522d994da51faad7ce92273f1ed0 /ethosu/vela/numeric_util.py | |
parent | eadb166072958febd7e222297d2a65bcf6063f01 (diff) | |
download | ethos-u-vela-f03bad31c194d1a24ce808223f1b00310a7325e2.tar.gz |
MLBEDSW-2031: LUT support tanh/sigmoid
Uses LUT for int8/uint8 based tanh/sigmoid.
Change-Id: Ib6ac5a5c958ab9a17e47f620b22c3e22d8d60321
Signed-off-by: Louis Verhaard <louis.verhaard@arm.com>
Diffstat (limited to 'ethosu/vela/numeric_util.py')
-rw-r--r-- | ethosu/vela/numeric_util.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/ethosu/vela/numeric_util.py b/ethosu/vela/numeric_util.py index 4ebef8e5..3d26444a 100644 --- a/ethosu/vela/numeric_util.py +++ b/ethosu/vela/numeric_util.py @@ -77,13 +77,17 @@ def clamp_tanh(x): 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 = 1 / (1 + math.exp(-x)) + y = sigmoid(x) return y |