From 017b4ccf9575a0f8ce604e2478fb09febbaa2875 Mon Sep 17 00:00:00 2001 From: Rickard Bolin Date: Fri, 23 Sep 2022 10:16:48 +0000 Subject: MLBEDSW-6928: Add int16 support for Resize Bilinear HPC Setting bias tensor dtype to DataType.int32 solves rounding issues for RB HPC int16. Removing the input data type check also solves the issue of resize nearest neighbor int16 ops incorrectly getting placed on the CPU. Signed-off-by: Rickard Bolin Change-Id: Iee352bcb78e581c0cde3c203dfbe866f1f6fae18 --- ethosu/vela/tflite_graph_optimiser.py | 2 +- ethosu/vela/tflite_supported_operators.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'ethosu') diff --git a/ethosu/vela/tflite_graph_optimiser.py b/ethosu/vela/tflite_graph_optimiser.py index 27513d3d..1310ee63 100644 --- a/ethosu/vela/tflite_graph_optimiser.py +++ b/ethosu/vela/tflite_graph_optimiser.py @@ -586,7 +586,7 @@ def convert_resizebilinear_to_depthwise_convolutions(op, half_pixel_centers=True # need to append the bias tensor as resize ops only have 2 inputs assert len(dw_conv.inputs) == 2 dw_conv.inputs.append(None) - fixup_bias_tensors(dw_conv, None, None) + fixup_bias_tensors(dw_conv, None, None, dtype=DataType.int32) dw_conv.set_ifm_ofm_shapes() dw_conv = dw_conv.clone(f"_{index}") diff --git a/ethosu/vela/tflite_supported_operators.py b/ethosu/vela/tflite_supported_operators.py index 9aa174de..8b448dfe 100644 --- a/ethosu/vela/tflite_supported_operators.py +++ b/ethosu/vela/tflite_supported_operators.py @@ -666,12 +666,12 @@ class TFLiteSupportedOperators: @staticmethod def constraint_resize_half_pixel_centers(op): - """Half_pixel_centers are only supported for resize bilinear with IFM dtype int8 or uint8""" - valid = op.ifm.dtype in (DataType.int8, DataType.uint8) + """Half_pixel_centers are only supported for resize bilinear""" + valid = True half_pixel_centers = op.attrs.get("half_pixel_centers", False) if half_pixel_centers and op.type != Op.ResizeBilinear: valid = False - return valid, f"Op type={op.type}, ifm dtype={op.ifm.dtype} and half_pixel_centers={half_pixel_centers}" + return valid, f"Op type={op.type} and half_pixel_centers={half_pixel_centers}" @staticmethod def constraint_resizebi_half_pixel_centers_dims(op): -- cgit v1.2.1