diff options
Diffstat (limited to 'ethosu/vela/tflite_model_semantic.py')
-rw-r--r-- | ethosu/vela/tflite_model_semantic.py | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/ethosu/vela/tflite_model_semantic.py b/ethosu/vela/tflite_model_semantic.py index dc3b8185..2851ab16 100644 --- a/ethosu/vela/tflite_model_semantic.py +++ b/ethosu/vela/tflite_model_semantic.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright 2021-2022 Arm Limited and/or its affiliates <open-source-office@arm.com> +# SPDX-FileCopyrightText: Copyright 2021-2023 Arm Limited and/or its affiliates <open-source-office@arm.com> # # SPDX-License-Identifier: Apache-2.0 # @@ -155,6 +155,10 @@ class TFLiteSemantic: self.specific_constraints[Op.Softmax].append(TFLiteSemantic.constraint_matching_in_out_types) self.specific_constraints[Op.Softmax].append(TFLiteSemantic.constraint_beta_value_range) + # Split specific checks: + self.specific_constraints[Op.Split].append(TFLiteSemantic.constraint_split_axis) + self.specific_constraints[Op.Split].append(TFLiteSemantic.constraint_split_num_splits) + # SplitV specific checks: self.specific_constraints[Op.SplitV].append(TFLiteSemantic.constraint_splitv_inferred) @@ -396,6 +400,29 @@ class TFLiteSemantic: return valid, f"Op has ifm_shape={ifm_shape} and ofm_shape={ofm_shape}" @staticmethod + def constraint_split_axis(op): + "Axis value must be in the range [-RANK(IFM) to +RANK(IFM))" + axis_tens = op.inputs[0] + input_tens = op.inputs[1] + dims = len(input_tens.shape) + axis = int(axis_tens.values) + axis += dims if axis < 0 else 0 + valid = 0 <= axis < dims + return valid, f"Op has ifm_dimensions={dims} and axis value is: {axis}" + + @staticmethod + def constraint_split_num_splits(op): + "Axis must be divisible by number of splits" + num_splits = op.attrs.get("num_splits") + axis_tens = op.inputs[0] + input_tens = op.inputs[1] + dims = len(input_tens.shape) + axis = int(axis_tens.values) + axis += dims if axis < 0 else 0 + valid = input_tens.shape[axis] % num_splits == 0 + return valid, f"Op has ifm shape={input_tens.shape} axis={axis} num_splits={num_splits}" + + @staticmethod def constraint_splitv_inferred(op): "Only one size is allowed to be inferred" sizes = op.inputs[1].values |