From 7b676498c2499428f238f68b0224dc3a8fbcb56e Mon Sep 17 00:00:00 2001 From: "erik.andersson@arm.com" Date: Mon, 18 Jan 2021 14:23:12 +0100 Subject: MLBEDSW-3858: Incorrect PAD usage bug Fixed a bug where PAD having no consumers would result in a crash. Now the constraint doesn't crash and thus the intended error message is shown, resulting in easier debugging. Change-Id: I1e4403d47a6152e7adbf7bc065db86d4217d39cc Signed-off-by: erik.andersson@arm.com --- ethosu/vela/supported_operators.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'ethosu/vela/supported_operators.py') diff --git a/ethosu/vela/supported_operators.py b/ethosu/vela/supported_operators.py index 9d315189..1bebe9af 100644 --- a/ethosu/vela/supported_operators.py +++ b/ethosu/vela/supported_operators.py @@ -829,17 +829,15 @@ class SupportedOperators: def constraint_pad_ofm(cls, op): "Must be followed by one of the following operator types: {}" consumers = op.ofm.consumers() - consumers_to_pad = 0 - for consumer in consumers: - if consumer.type in cls.supported_pad_consumers: - if consumer.attrs["padding"] == Padding.VALID: - consumers_to_pad += 1 - valid = len(consumers) > 0 and len(consumers) == consumers_to_pad - return ( - valid, - f"Operator is followed by {consumers_to_pad} consumers with " - f"padding set to VALID, out of {len(consumers)} consumers", - ) + unsupported_consumers = [ + cons.type + for cons in consumers + if cons is not None + if cons.type not in cls.supported_pad_consumers or cons.attrs["padding"] != Padding.VALID + ] + [None for cons in consumers if cons is None] + none_string = ", ".join(["NoneType" for cons in consumers if cons is None]) + valid = len(unsupported_consumers) == 0 + return valid, f"PAD operator is followed by: {_optype_formatter(unsupported_consumers)+none_string}" @staticmethod def constraint_stridedslice_inputs_const(op): -- cgit v1.2.1