From ba2555e9fe9a93a308cc4e50f6a8a160571cb563 Mon Sep 17 00:00:00 2001 From: "erik.andersson@arm.com" Date: Thu, 28 Oct 2021 14:08:52 +0200 Subject: MLBEDSW-4925: Fix resize bilinear attribute check Previously we did not check if half_pixel_centers was set. Since we do not support it, these cases should not run on the NPU. Signed-off-by: erik.andersson@arm.com Change-Id: I9d2675f760424d5cfb67e5d581dd1861ad165b85 --- ethosu/vela/test/test_tflite_supported_operators.py | 7 +++++++ ethosu/vela/tflite_supported_operators.py | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/ethosu/vela/test/test_tflite_supported_operators.py b/ethosu/vela/test/test_tflite_supported_operators.py index af5dc174..e3db7913 100644 --- a/ethosu/vela/test/test_tflite_supported_operators.py +++ b/ethosu/vela/test/test_tflite_supported_operators.py @@ -327,6 +327,13 @@ def test_constraint_resize(): assert not support.is_operator_supported(op) +def test_constraint_bilinear_resize_attrs(): + op = testutil.create_op_with_quant_tensors(Op.ResizeBilinear, [1, 1, 1, 8], [1, 8, 8, 8]) + assert support.is_operator_supported(op) + op.attrs["half_pixel_centers"] = True + assert not support.is_operator_supported(op) + + def test_constraint_concat_pass(): # A working concat op = testutil.create_op_with_quant_tensors(Op.Concat, [1, 1, 1, 4], [1, 1, 1, 8]) diff --git a/ethosu/vela/tflite_supported_operators.py b/ethosu/vela/tflite_supported_operators.py index d590054f..a3c0dd8d 100644 --- a/ethosu/vela/tflite_supported_operators.py +++ b/ethosu/vela/tflite_supported_operators.py @@ -162,6 +162,7 @@ class TFLiteSupportedOperators: # Resizing specific checks: for op_type in TFLiteSupportedOperators.resizing_ops: self.specific_constraints[op_type].append(TFLiteSupportedOperators.constraint_resize) + self.specific_constraints[op_type].append(TFLiteSupportedOperators.constraint_bilinear_resize_attrs) # Vector Product specific checks: for op_type in TFLiteSupportedOperators.fc_vector_products: @@ -529,6 +530,14 @@ class TFLiteSupportedOperators: break return valid, f"Op has ifm_shape={ifm_shape}, ofm_shape={ofm_shape} and align_corners={align_corners}" + @staticmethod + def constraint_bilinear_resize_attrs(op): + "half_pixel_centers are not supported" + valid = True + if op.attrs.get("half_pixel_centers"): + valid = False + return valid, f"Op has half_pixel_centers set to {not valid}." + @staticmethod def constraint_pad_shape(op): "The padding tensor must have the shape [3,2] or [4,2]" -- cgit v1.2.1