MLBEDSW-2688: LUT calculation with different in/out scale

Enables LUT for LeakyRelu with int8/uint8 even if input scale
is different from the output scale.

Fusing LUT with a previous operator for this situation
requires further work.

Change-Id: I9eddfe36f457e763d44eb3e05fbe240eac7cfec9
Signed-off-by: Louis Verhaard <louis.verhaard@arm.com>
diff --git a/ethosu/vela/fp_math.py b/ethosu/vela/fp_math.py
index 2055879..eaeb84a 100644
--- a/ethosu/vela/fp_math.py
+++ b/ethosu/vela/fp_math.py
@@ -136,3 +136,13 @@
         return np.iinfo(np.int32).max
     else:
         return result
+
+
+def multiply_by_quantized_multiplier(x, scale, shift):
+    # Multiplies x (int32) by (scale, shift) which have obtained by a call to scaling.quantize_scale,
+    # returns rounded result
+    shift = 31 - shift
+    left_shift = shift if shift > 0 else 0
+    right_shift = -shift if shift < 0 else 0
+    mul = saturating_rounding_mul(x * (1 << left_shift), scale)
+    return rounding_divide_by_pot(mul, right_shift)