From 7ede3176636c20465851daf9ff1f9210e4902264 Mon Sep 17 00:00:00 2001 From: Johan Alfven Date: Thu, 4 May 2023 12:47:25 +0200 Subject: MLBEDSW-7542: Fix output diff caused by wrong scaling in Conv2d - The reference calculates the scale slightly different between Conv2d and FullyConnect. Recently a fix was submitted to address this issue. However, internally a Conv2d can be changed to a FullyConnect but then the scale must still be calculated following the Conv2d reference. - The fix is to check the original type if FullyConnect scale should be used or not. Change-Id: I5a9fb49126f0df63712b73fb5520fdc604cee378 Signed-off-by: Johan Alfven --- ethosu/vela/weight_compressor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ethosu') diff --git a/ethosu/vela/weight_compressor.py b/ethosu/vela/weight_compressor.py index a37ff6af..a258be41 100644 --- a/ethosu/vela/weight_compressor.py +++ b/ethosu/vela/weight_compressor.py @@ -284,7 +284,7 @@ def _prepare_scale_and_bias(arch, tens, rescale_for_faf, explicit_scaling): # TensorFlow Lite casts the scales slightly differently for uint8 and int8 as well as # for FullyConnected operators if not rescale_for_faf: - if ifm_dtype == DataType.uint8 or first_consumer_op.type == Op.FullyConnected: + if ifm_dtype == DataType.uint8 or first_consumer_op.original_type == Op.FullyConnected: scales = [np.double(ifm_scale * weight_scale) / np.double(ofm_scale) for weight_scale in weight_scales] elif ifm_dtype == DataType.int8 or ifm_dtype == DataType.int16: scales = [ -- cgit v1.2.1