From 3f22ec2025c8e1afe6780785fd8c62c015824a63 Mon Sep 17 00:00:00 2001 From: Patrik Gustavsson Date: Tue, 21 Sep 2021 14:18:44 +0200 Subject: TOSA: Decompose elem op tensors Added decomposition of tensors exceeding maximum size supported by NPU. Signed-off-by: Patrik Gustavsson Change-Id: I17a99cb72947d2f1064a631ad6975ce895c258d5 --- ethosu/vela/tosa_supported_operators.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'ethosu/vela/tosa_supported_operators.py') diff --git a/ethosu/vela/tosa_supported_operators.py b/ethosu/vela/tosa_supported_operators.py index f5eddccc..1012a615 100644 --- a/ethosu/vela/tosa_supported_operators.py +++ b/ethosu/vela/tosa_supported_operators.py @@ -117,18 +117,19 @@ class TosaSupportedOperators: # This is for a HW limitation, that is to be resolved in SW later on @classmethod @docstring_format_args(tens_dim_range) - def constraint_tens_dimension(cls, op): - "Tensor dimensions must be in the range [{}, {}]" - tens_min, tens_max = cls.tens_dim_range + def constraint_tens_dimension(self, op): + "Tensor dimensions must be in the range [{}, {}], if not elementwise" + tens_min, tens_max = self.tens_dim_range valid = True extra = [] - tensors = [tens for tens in op.get_ifm_ifm2_weights_ofm() if tens] - if not tensors: - tensors = [tens for tens in op.inputs if tens] - for tens in tensors: - if not all(tens_min <= dim <= tens_max for dim in tens.shape): - valid = False - extra.append(f"Tensor '{tens.name}' has shape: {tens.shape}") + if op.type not in self.binary_elem_wise_add_mul_sub: + tensors = [tens for tens in op.get_ifm_ifm2_weights_ofm() if tens] + if not tensors: + tensors = [tens for tens in op.inputs if tens] + for tens in tensors: + if not all(tens_min <= dim <= tens_max for dim in tens.shape): + valid = False + extra.append(f"Tensor '{tens.name}' has shape: {tens.shape}") return valid, ", ".join(extra) # TODO This is for a HW limitation, that is to be resolved in SW later on -- cgit v1.2.1