MLBEDSW-6313 Static optimisation for Shape OP

*Shape OP value is available at compile time hence
it can be optimised
*Disconnected shape OP at compile time from parent
tensor
*Transformed shape OP tensor into constant

Change-Id: I0a024269e2b592c6146dd72e62d7a41951fb727a
Signed-off-by: Ayaan Masood <Ayaan.Masood@arm.com>
diff --git a/ethosu/vela/tflite_model_semantic.py b/ethosu/vela/tflite_model_semantic.py
index e0541df..ee66d4c 100644
--- a/ethosu/vela/tflite_model_semantic.py
+++ b/ethosu/vela/tflite_model_semantic.py
@@ -186,7 +186,15 @@
         if op.type in (Op.Placeholder, Op.SubgraphInput, Op.Const):
             return True
 
-        for constraint in self.generic_constraints + self.specific_constraints[op.type]:
+        # Generic constraints list filtered out to exclude certain constraints depending on op.type
+        filtered_generic_constraints = []
+
+        for constraint in self.generic_constraints:
+            # Check constraint not in dictionary otherwise return empty array
+            if constraint not in self.get_generic_constraint_exclude_list().get(op.type, []):
+                filtered_generic_constraints.append(constraint)
+
+        for constraint in filtered_generic_constraints + self.specific_constraints[op.type]:
             valid, extra = constraint(op)
             if not valid:
                 print(
@@ -200,6 +208,19 @@
         return True
 
     @staticmethod
+    def get_generic_constraint_exclude_list():
+
+        # Not all generic constraints can be applied to each operator
+        generic_constraints_exclude_list = {
+            Op.Shape: [
+                TFLiteSemantic.constraint_tens_quant_none_check,
+                TFLiteSemantic.constraint_tens_quant_scale,
+                TFLiteSemantic.constraint_quant_scale_inf,
+            ]
+        }
+        return generic_constraints_exclude_list
+
+    @staticmethod
     def constraint_none_const_tensors(op):
         "Constant tensors should not have NoneType-values"
         valid = True