aboutsummaryrefslogtreecommitdiff
path: root/ethosu/vela/register_command_stream_generator.py
diff options
context:
space:
mode:
Diffstat (limited to 'ethosu/vela/register_command_stream_generator.py')
-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 d74f4d24..fd32b655 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: