MLBEDSW-2813: Handle non-const weights and check shapes
- Added check for non-constant weights in supported operators
- Added check ifm & ifm2 shapes
- Handle None tensors for CPU operators
- Handle missing attributes for Cast operator
Signed-off-by: Andreas Nevalainen <andreas.nevalainen@arm.com>
Change-Id: I2f16d3d44d0c6da5237550b39273cdb9cc3c7607
diff --git a/ethosu/vela/supported_operators.py b/ethosu/vela/supported_operators.py
index b6551cf..b0afa2c 100644
--- a/ethosu/vela/supported_operators.py
+++ b/ethosu/vela/supported_operators.py
@@ -227,6 +227,12 @@
# check batch size
if ifm_tensor.shape[0] != 1:
return False
+
+ # check non const weights
+ if weight_tensor.values is None:
+ print("Warning:", op.type, "has non-const weights, placing on CPU")
+ return False
+
return True
def check_depthwise_convolution_restrictions(self, op):
@@ -317,6 +323,11 @@
if not self.check_bias_restrictions(bias_tensor):
return False
+ # check non const weights
+ if weight_tensor.values is None:
+ print("Warning:", op.type, "has non-const weights, placing on CPU")
+ return False
+
return True
def check_element_wise_restrictions(self, op):
@@ -362,6 +373,10 @@
if op.type == "LeakyRelu" and op.attrs["alpha"] < 0:
return False
+ # check if ifm or ifm2 has ofm shape
+ if ifm_tensor.shape != ofm_tensor.shape and ifm2_tensor.shape != ofm_tensor.shape:
+ return False
+
return True
def check_memory_only_restrictions(self, op):