Skip to content

Commit 2bd09f9

Browse files
committed
Arm backend: Fix mult and scale calculation for int48_t
Signed-off-by: Per Åstrand <[email protected]> Change-Id: Ibe158d8d35a632547290f1b9a055d061ae267d77
1 parent edc1c42 commit 2bd09f9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

backends/arm/tosa/quant_utils.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,9 @@ def compute_multiplier_and_shift(
268268
if shift > 62:
269269
multiplier = multiplier >> min(31, shift - 62)
270270
shift = 62
271+
272+
assert multiplier >= 0, "Multiplier should be non-negative"
273+
assert shift >= 2 and shift <= 62, "Shift should be in range [2, 62]"
271274
multipliers.append(multiplier)
272275
shifts.append(shift)
273276
return multipliers, shifts
@@ -322,8 +325,8 @@ def build_rescale(
322325

323326
import tosa.Op as TosaOp # type: ignore
324327

325-
scaleWidth = 32
326-
is_scale32 = True
328+
scaleWidth = 16 if input_node.dtype == ts.DType.INT48 else 32
329+
is_scale32 = False if input_node.dtype == ts.DType.INT48 else True
327330
multipliers, shifts = compute_multiplier_and_shift(scale, scaleWidth)
328331
rescale_inputs = create_const_ops_for_rescale(
329332
tosa_fb,

0 commit comments

Comments
 (0)