From ac111101cccbdeddb4bef91a0a7b142e33c365c1 Mon Sep 17 00:00:00 2001 From: Johan Alfven Date: Tue, 9 May 2023 16:33:41 +0200 Subject: MLBEDSW-7578: Fix output diff caused by wrong rounding in Conv2d - The reference calculates the rounding different between int8 and int16 for Conv2d. However, internally a Conv2d can be changed to a FullyConnect but then the rounding must still be calculated following the Conv2d reference. - The fix is to check the original type if NATURAL rounding should be used or not. int16 Conv2d uses NATURAL rounding in reference. Change-Id: I80d48b54372ef7b978ee2e9384a01934dd454e24 Signed-off-by: Johan Alfven --- ethosu/vela/high_level_command_to_npu_op.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ethosu/vela/high_level_command_to_npu_op.py') diff --git a/ethosu/vela/high_level_command_to_npu_op.py b/ethosu/vela/high_level_command_to_npu_op.py index 7634fe1f..55b44730 100644 --- a/ethosu/vela/high_level_command_to_npu_op.py +++ b/ethosu/vela/high_level_command_to_npu_op.py @@ -134,7 +134,7 @@ def get_rounding_mode(op: Operation, fused_quantize: bool) -> NpuRoundingMode: if op.type.is_resize_op(): rounding_mode = NpuRoundingMode.NATURAL elif ( - op.type.npu_block_type in (NpuBlockType.ConvolutionMxN, NpuBlockType.ConvolutionDepthWise) + op._original_type.npu_block_type in (NpuBlockType.ConvolutionMxN, NpuBlockType.ConvolutionDepthWise) and op.ifm.dtype == DataType.int16 ): rounding_mode = NpuRoundingMode.NATURAL -- cgit v1.2.1