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 --- SUPPORTED_OPS.md | 6 +++--- ethosu/vela/tflite_graph_optimiser.py | 2 +- ethosu/vela/tflite_supported_operators.py | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/SUPPORTED_OPS.md b/SUPPORTED_OPS.md index 36b403ad..3ccf3ab5 100644 --- a/SUPPORTED_OPS.md +++ b/SUPPORTED_OPS.md @@ -1,7 +1,7 @@ # Supported Ops This file was automatically generated by Vela using the `--supported-ops-report` parameter. -Vela version: `3.5.1.dev14+gc22ad76.d20220921` +Vela version: `3.6.0rc1.dev11+gac5e33e` This file complies with [**Gitiles Markdown syntax**](https://github.com/google/gitiles/blob/master/Documentation/markdown.md) @@ -280,7 +280,7 @@ This is a list of constraints that the RESIZE_BILINEAR operator must satisfy in W and H scaling must be equal and OFM W and H must be 2x/4x/8x IFM W and H, if align_corners is False - The size tensor must match the output tensor shape - Both align_corners and half_pixel_centers can't be True -- Half_pixel_centers are only supported for resize bilinear with IFM dtype int8 or uint8 +- Half_pixel_centers are only supported for resize bilinear - Half_pixel_centers for resize bilinear requires that OFM W and H is 2x IFM W and H ### TFLite RESIZE_NEAREST_NEIGHBOR Constraints @@ -294,7 +294,7 @@ This is a list of constraints that the RESIZE_NEAREST_NEIGHBOR operator must sat W and H scaling must be equal and OFM W and H must be 2x/4x/8x IFM W and H, if align_corners is False - The size tensor must match the output tensor shape - Both align_corners and half_pixel_centers can't be True -- Half_pixel_centers are only supported for resize bilinear with IFM dtype int8 or uint8 +- Half_pixel_centers are only supported for resize bilinear ### TFLite SOFTMAX Constraints 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