aboutsummaryrefslogtreecommitdiff
path: root/ethosu
diff options
context:
space:
mode:
authorJohan Alfvén <johan.alfven@arm.com>2022-10-17 12:29:12 +0200
committerJohan Alfvén <johan.alfven@arm.com>2022-10-18 08:42:36 +0200
commita64616c4d7a33c5b2b4e5fb38c57217dc65bc2ea (patch)
tree6b591bbbe0bb0b1527c0d1119fe9d5adde72b6f9 /ethosu
parentb81e1bb92be8ea5b29625cf2f361e9160286b16a (diff)
downloadethos-u-vela-a64616c4d7a33c5b2b4e5fb38c57217dc65bc2ea.tar.gz
MLBEDSW-6794: ResizeNearestNeighbor with HPC
- Removed half pixel centers constraint for resize nearest neightbor. - Supported scale 2x, 4x and 8x. - Removed test_constraint_resize_half_pixel_centers - Regenerated SUPPORTED_OPS.md Signed-off-by: Johan Alfven <johan.alfven@arm.com> Change-Id: Ic3e02e9c2b2034d537c9a9841b8fb4ee433c96dc
Diffstat (limited to 'ethosu')
-rw-r--r--ethosu/vela/test/test_tflite_supported_operators.py12
-rw-r--r--ethosu/vela/tflite_graph_optimiser.py4
-rw-r--r--ethosu/vela/tflite_supported_operators.py10
3 files changed, 3 insertions, 23 deletions
diff --git a/ethosu/vela/test/test_tflite_supported_operators.py b/ethosu/vela/test/test_tflite_supported_operators.py
index 35fc1a6f..790f0018 100644
--- a/ethosu/vela/test/test_tflite_supported_operators.py
+++ b/ethosu/vela/test/test_tflite_supported_operators.py
@@ -381,18 +381,6 @@ def test_constraint_resize_attrs():
assert not support.is_operator_supported(op)
-def test_constraint_resize_half_pixel_centers():
- for resize_op in Op.op_set(Op.is_resize_op):
- # Half-pixel centers is only supported for resize bilinear
- op = testutil.create_op_with_quant_tensors(resize_op, [1, 4, 4, 8], [1, 8, 8, 8])
- op.add_input_tensor(create_const_tensor("size", [2], DataType.int32, [8, 8], np.int32))
- op.attrs["half_pixel_centers"] = True
- if resize_op == Op.ResizeBilinear:
- assert support.is_operator_supported(op)
- else:
- 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_graph_optimiser.py b/ethosu/vela/tflite_graph_optimiser.py
index f3ca1b63..574d298a 100644
--- a/ethosu/vela/tflite_graph_optimiser.py
+++ b/ethosu/vela/tflite_graph_optimiser.py
@@ -454,7 +454,9 @@ def convert_resize_to_upscale_and_average_pool(op):
# use depthwise conv to select the correct value
scaled_op = convert_resizenn_ac_to_depthwise_conv(scaled_op, upscale_factor)
else:
- # keep 1x1 kernel and average pool
+ # Keep 1x1 kernel and average pool, this applies both when
+ # half-pixel-centers is True and False. Calculations are the
+ # same in the reference.
pass
scaled_op.outputs = outputs
diff --git a/ethosu/vela/tflite_supported_operators.py b/ethosu/vela/tflite_supported_operators.py
index 3d04def3..23bbac24 100644
--- a/ethosu/vela/tflite_supported_operators.py
+++ b/ethosu/vela/tflite_supported_operators.py
@@ -264,7 +264,6 @@ class TFLiteSupportedOperators:
self.specific_constraints[op_type].append(TFLiteSupportedOperators.constraint_resize)
self.specific_constraints[op_type].append(TFLiteSupportedOperators.constraint_resize_size)
self.specific_constraints[op_type].append(TFLiteSupportedOperators.constraint_resize_attrs)
- self.specific_constraints[op_type].append(TFLiteSupportedOperators.constraint_resize_half_pixel_centers)
# Resize Bilinear specific checks:
self.specific_constraints[Op.ResizeBilinear].append(
@@ -682,15 +681,6 @@ class TFLiteSupportedOperators:
return valid, "Op has both align_corners and half_pixel_centers set to True."
@staticmethod
- def constraint_resize_half_pixel_centers(op):
- """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} and half_pixel_centers={half_pixel_centers}"
-
- @staticmethod
def constraint_resizebi_half_pixel_centers_dims(op):
"""Half_pixel_centers for resize bilinear requires that OFM W and H is 2x IFM W and H"""
half_pixel_centers = op.attrs.get("half_pixel_centers", False)