aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFredrik Svedberg <fredrik.svedberg@arm.com>2023-05-08 16:13:43 +0200
committerFredrik Svedberg <fredrik.svedberg@arm.com>2023-05-10 09:27:45 +0000
commit5fd155eb8f1d8da61f5d5dc8a925e8fb090c99d6 (patch)
tree421fbe51eb28071840726b1ed72fa9283e9451aa
parentfe85315f90d142b48df3f71bd1c34eef08fc66d8 (diff)
downloadethos-u-vela-5fd155eb8f1d8da61f5d5dc8a925e8fb090c99d6.tar.gz
MLBEDSW-7572 Update LSTM with new constant precision
Updated the Q0_15_SCALE constant to match the updated value in the reference. Change-Id: Id680748c532d41fea9760ec76c0b65c0c3e73a13 Signed-off-by: Fredrik Svedberg <fredrik.svedberg@arm.com>
-rw-r--r--ethosu/vela/lstm.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/ethosu/vela/lstm.py b/ethosu/vela/lstm.py
index 5a50788b..ecec58f4 100644
--- a/ethosu/vela/lstm.py
+++ b/ethosu/vela/lstm.py
@@ -37,7 +37,7 @@ from .shape4d import Shape4D
from .tensor import QuantizationParameters
from .tensor import Tensor
-Q0_15_SCALE = np.float32(0.00003051757)
+Q0_15_SCALE = np.float32(2**-15)
"""Q0.15 scale like the reference defines it"""
@@ -248,7 +248,7 @@ class Lstm:
re_fc.ofm.dtype = DataType.int16
# Setup add quantization
q_add = q_fc.clone()
- q_add.scale_f32 = np.float32(2**-15)
+ q_add.scale_f32 = Q0_15_SCALE
# Create add + activation
add = create_add(f"{name}_add", in_fc.ofm, re_fc.ofm, q_add, ActivationFunction(activation))
if activation is Op.Sigmoid:
@@ -309,7 +309,7 @@ class Lstm:
base_name = f"output_state#{batch}.{time}"
# Setup tanh quantization
q_out_tanh = QuantizationParameters()
- q_out_tanh.scale_f32 = np.float32(2**-15)
+ q_out_tanh.scale_f32 = Q0_15_SCALE
q_out_tanh.zero_point = 0
# Create tanh(cell state)
tanh = create_fused_activation(Op.Tanh, f"{base_name}_tanh", cell_state, q_out_tanh)