aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrik Gustavsson <patrik.gustavsson@arm.com>2021-12-02 09:08:26 +0100
committerPatrik Gustavsson <patrik.gustavsson@arm.com>2021-12-02 09:47:46 +0100
commite3dd2f3c4e09488776d45e8884123385b3e93e2a (patch)
treefefe7b7e7cd50ba91400fb36052103a1a2da6310
parenteed30eacb543cc1da8adc4bddce555787bd96a73 (diff)
downloadethos-u-vela-e3dd2f3c4e09488776d45e8884123385b3e93e2a.tar.gz
MLBEDSW-5717 Fix for sigmoid int16
Fixed issue with sigmoid int16 with 1/2048 scaling. Signed-off-by: Patrik Gustavsson <patrik.gustavsson@arm.com> Change-Id: I32718757e3776e6be89fe94a9b38368c78f0006b
-rw-r--r--ethosu/vela/register_command_stream_generator.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/ethosu/vela/register_command_stream_generator.py b/ethosu/vela/register_command_stream_generator.py
index d74f4d2..fd32b65 100644
--- a/ethosu/vela/register_command_stream_generator.py
+++ b/ethosu/vela/register_command_stream_generator.py
@@ -656,8 +656,11 @@ def generate_ofm_scaling_for_pooling(emit: CommandStreamEmitter, pool_op: NpuPoo
rounded_log2 = int(round(x_log2))
is_power_of_two = abs(x_log2 - rounded_log2) < 0.001
shift = rounded_log2 + 12
- if is_power_of_two and shift in (0, 1):
- # Special handling if input scale is 1/2048 or 1/4096
+ if is_power_of_two and (
+ (pool_op.activation.op_type == NpuActivationOp.TANH and shift in (0, 1))
+ or (pool_op.activation.op_type == NpuActivationOp.SIGMOID and shift == 0)
+ ):
+ # Special handling if input scale is 1/2048 (tanh/sigmoid) or 1/4096 (tanh)
scale = 3 << shift
shift = 0
else: